0

Today i read:

Don’t use single quotation marks around paths for images. When setting a background image, resist the urge to surround the path with quote marks. They’re not necessary, and IE5/Mac will choke.

Meaning instead of:

<img src="pic_mountain.jpg" title="Mountain-View" style="width:304px;height:228px;">

this:

<img src=pic_mountain.jpg title=Mountain-View style=width:304px;height:228px;>

should be perfectly fine. Is this true? No diffrences? It does work normally on my end. Is it about cross-browser compatibility? Source for the info: Source

deceze
  • 510,633
  • 85
  • 743
  • 889
Herrsocke
  • 272
  • 4
  • 13
  • Yes, quote-less attributes are officially supported syntax. Read [the spec](https://www.w3.org/TR/html-markup/syntax.html#syntax-attributes). Whether you should still care about IE5/Mac is extremely debatable… – deceze Nov 04 '16 at 15:16

2 Answers2

3

The quote is talking about CSS, not HTML.

These all mean the same in CSS:

background-image: url(/path/to/foo);
background-image: url("/path/to/foo");
background-image: url('/path/to/foo');

… except only the first one works in IE5/Mac … which hasn't been supported for a very long time, so isn't worth worrying about.


The two versions of HTML in your question are (for reasons unrelated to the quote you included) also equivalent.

The common view about best practise is that you should always place quotes around HTML attribute values. It saves having to remember which characters that you might want to place in an attribute value turn the quote from optional into required. Space is an obvious example of such a character.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

It is valid html but if you then use an attribute that is not valid for an element it will then through an error this link should help.

unquoted attributes

Dcoto
  • 143
  • 9
  • 1
    *"but if you then use an attribute that is not valid for an element it will then through an error"* – Wut?! – deceze Nov 04 '16 at 15:18