Reputation: 61
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>
Upvotes: 1
Views: 3715
Reputation: 23
Try this
<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>
Upvotes: 0
Reputation: 354
In target attribute you need to add _ before giving any target. like
target="_blank"
target="_self"
target="_top"
Upvotes: 2
Reputation: 155448
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.
Upvotes: 5