HTML - attributes - target

revision:


Content

"target" attribute : specifies where a link will be opened syntax some examples


"target" attribute : specifies where a link will be opened

top

The target attribute specifies where to open the linked document.

The target attribute can be used on following elements: <a>, <area>, <base>, <form>.

For <a> and <area> elements, the target attribute specifies where to open the linked document.

For <base> elements, the target attribute specifies the default target for all hyperlinks and forms in the page.

For <form> elements, the target attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.


syntax

top

<element target="_blank | _self | _parent | _top | framename"></element>

attribute values:

_blank: opens the linked document in a new window or tab.

_self: opens the linked document in the same frame as it was clicked (this is default).

_parent: opens the linked document in the parent frame.

_top: opens the linked document in the full body of the window

framename: opens the linked document in the named iframe


some examples

top

Open link in a new window or tab: Visit my website!

codes
                    <p class="spec">Open link in a new window or tab: <a href="https://www.lwitters.com" 
                    target="_blank">Visit my website!</a></p>
                




codes:
                    <form style="margin-left:3vw;" action="/action_page.php" method="get" target="_blank">
                        <label for="fname">First name:</label>
                        <input type="text" id="fname" name="fname"><br><br>
                        <label for="lname">Last name:</label>
                        <input type="text" id="lname" name="lname"><br><br>
                        <input type="submit" value="Submit">
                    </form>