7

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.

Kathan
  • 1,428
  • 2
  • 15
  • 31
  • 4
    There is no difference functionally. It's generally agreed that best practice IS to use quotes. [Do you quote HTML5 attributes?](http://stackoverflow.com/questions/6495310/do-you-quote-html5-attributes) – CollinD Sep 25 '15 at 03:25
  • Both are valid but use of quotes adheres more to the XHTML specification. I'd say the best practice is with quotes. – Eraph Sep 25 '15 at 03:27
  • What about target=blank without the underscore? That seems to work too. – Costa Michailidis Aug 13 '20 at 17:33

2 Answers2

11

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
Community
  • 1
  • 1
Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
2

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.

Matt Komarnicki
  • 5,198
  • 7
  • 40
  • 92