HTML form Tag target Attribute Tutorial

In this section, we will learn what target attribute is and how to use it.

What is target Attribute in HTML <form> Tag?

When submitting forms to servers, they usually send back a response which declares if the operation was a success or a failure. We need to declare where this response document should be displayed.

This is where the target attribute comes in.

The value of this attribute declares the location in which the response document will be displayed in.

For example, one of the values we could put to this attribute is “_blank” and that means display the response on a new browser window or tab without closing the current document.

HTML target Attribute in <form> Tag Syntax:

<form target = “value”> </form>

<form> Tag target Attribute Values

Here is the list of values we could use for the target attribute:

Name

Description

_blank

Open the linked document on a new tab or window.

_self

Open the linked document on the window of the current document.

_parent

Open the linked document on the parent frame

_top

Open the linked document on the full body of the window

framename

Open the linked document on the specified iframe.

Example: using target attribute in HTML <form> tag

See the Pen using target attribute in HTML <form> tag by Omid Dehghan (@odehghan) on CodePen.

For this example, the server’s response will be in a new browser tab or window.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies