anchor tag “target” attribute is not working

2595 views html
3

I am facing a great problem in HTML.

The anchor tag “target” attribute is not working.

Here is my code

<div class="gallery_img">
   <img src="image/room1.jpg" alt="">
           <div class="hover">
<a class="light" href="image/room1.jpg" target="blank"><i class="fa fa-expand"></i></a>
      </div>
 </div>

answered question

..i use target="blank" on previous time..but its was works properly....Now at this time its not working ....Thanks You So much for helping!!

2 Answers

6

It's target="_blank", not target="blank".

MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a

target Specifies where to display the linked URL. It is a name of, or keyword for, a browsing context: a tab, window, or <iframe>. The following keywords have special meanings:

  • _self: Load the URL into the same browsing context as the current one. This is the default behavior.
  • _blank: Load the URL into a new browsing context. This is usually a tab, but users can configure browsers to use new windows instead.
  • _parent: Load the URL into the parent browsing context of the current one. If there is no parent, this behaves the same way as _self.
  • _top: Load the URL into the top-level browsing context (that is, the "highest" browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this behaves the same way as _self.

I am of the opinion that websites generally should not use target="_blank" because websites should not assume that the user actually wants the link to open in a new window or tab, especially because it can break the user's history and back button.

posted this
8

In target attribute you need to add _ before giving any target. like

target="_blank"
target="_self"
target="_top"

posted this

Have an answer?

JD

Please login first before posting an answer.