Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

target = "_blank" vs. target = _blank

Tags:

html

Is there any difference between target="_blank" and target=_blank ?

Seems to have the same behavior, but just want to make sure if one is better to practice than the other (and why). I have always used quotes, but am reading the rails tutorial and realized Michael does not use them.

like image 338
Kathan Avatar asked Sep 25 '15 03:09

Kathan


People also ask

Should you use target _blank?

The target=”_blank” link attribute is risky and opens a website to security and performance issues. Google's Web. dev page on the risks of using the _blank link attribute is summarized as such: “The other page may run on the same process as your page.

What does a target _blank do?

A target attribute with the value of “_blank” opens the linked document in a new window or tab. A target attribute with the value of “_self” opens the linked document in the same frame as it was clicked (this is the default and usually does not need to be specified).

What is the opposite of target _blank?

In short, use target="_blank" it always open a new window but use target="blank" it will open a new window at the first time and this window will be reused after the first. Save this answer.

What does the reserved target name _blank signify?

_blank: It opens the link in a new window. _self: It opens the linked document in the same frame. it is the default value. _parent: It opens the linked document in the parent frameset.


2 Answers

They are equivalent.

The HTML attribute syntax allows for quoted and unquoted attributes.

In addition to the general requirements for attribute values, an unquoted attribute value has the following restrictions:

  • must not contain any literal space characters
  • must not contain any """, "'", "=", ">", "<", or "`", characters
  • must not be the empty string
like image 190
Jonathon Reinhart Avatar answered Oct 23 '22 19:10

Jonathon Reinhart


Always use first approach. When you define an attribute, surround it's value with double quotes. While both can work, second seems to be messy and inconsistent as well as can lead to some issues with older browsers.

like image 44
Matt Komarnicki Avatar answered Oct 23 '22 18:10

Matt Komarnicki