I came across a question on GeeksforGeeks listed as a “Top HTML Interview Question,” which says:
The HTML target Attribute is used to specify the window or a frame where the linked document is loaded. It is not supported by HTML5.
They even provide syntax like this:
<link target="_blank|_self|_parent|_top|framename">
However, ChatGPT claims that this is incorrect because the <link>
tag never supports the target attribute in any version of HTML, and the target attribute is only valid for the <a>
(anchor) tag.
This leaves me confused because:
- If the
target
attribute isn’t supported for<link>
, why is this being mentioned as a “Top Interview Question”? - GeeksforGeeks also refers to the
<link>
tag with thetarget
attribute in other places on their site, so it doesn’t seem like a one-off mistake. - Is this a typo where they meant to refer to the
<a>
tag instead of<link>
? Or is there some historical context to<link>
andtarget
that I’m missing?
If anyone can clarify this or provide more insights, I’d really appreciate it. Thanks!
I tried researching the target
attribute in the <link>
tag to understand if it’s supported in any version of HTML.
- I checked multiple HTML references (like MDN and W3Schools), which all stated that the
target
attribute is only valid for<a>
tags and not<link>
. - I also tested
<link target="_blank">
in an HTML5 document to see if it had any effect, but it did nothing in the browser. - I expected to find a clear explanation of whether the target attribute ever applied to
<link>
or if this is a mistake in the GeeksforGeeks article.
Ibnu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
13