4

I am working on a web site, and am wondering if you need to put quotation marks around HTML attributes for example I've seen code like:
<img src=http://example.com/image.jpg width=350px height=200px />
instead of:
<img src="http://example.com/image.jpg" width="350px" height="200px" />.
Does anyone know the answer to this?

Pete K.
  • 92
  • 3
  • 11

1 Answers1

9

If the attribute contains a string that is not ascii or has whitespace then you need to wrap it in quotes

Attributes are placed inside the start tag, and consist of a name and a value, separated by an "=" character. The attribute value can remain unquoted if it doesn't contain ASCII whitespace or any of " ' ` = < or >. Otherwise, it has to be quoted using either single or double quotes. The value, along with the "=" character, can be omitted altogether if the value is the empty string.

link here

repzero
  • 7,924
  • 2
  • 14
  • 38