http://cssdweb.edu/Student Resources/Website Development I/CodeSamples/AttributeQuotesText.html

This is a test of the statement in the last paragraph on page 79 in Fundamentals of Web Development, Third Edition by Randy Connolly and Ricardo Hoar that says that enclosing attribute values in quotes is optional in HTML5.

That paragraphs says:

HTML elements can also contain attributes. An HTML attribute is a name=value pair that provides more information about the HTML element. In XHTML, attribute values had to be enclosed in quotes; in HTML5, the quotes are optional, though many web authors still maintain the practice of enclosing attributes values in quotes.

But look at these examples:

This is the first example. It is a paragraph tag with a style attribute. The paragraph is intended to be displayed in blue text, but the style attribute value is not enclosed in quotes. It is coded as follows:

<p style=color: blue>This is the first example. ...</p>

This is the second example. It is also a paragraph tag with a style attribute. Like the previous paragraph, it is intended to be displayed in blue text, but this time the style attribute value is enclosed in quotes. It is coded as follows:

<p style="color: blue">This is the second example. ...</p>

Thus, I strongly disagree with the book’s authors.

It would be OK to say: “attribute values that consist of a single word need not be enclosed in quotes, but attribute values that consist of multiple words must still be enclosed in quotes.” However, the general statement that enclosing HTML5 attributes in quotes is optional is simply wrong, as the above examples clearly demonstrate.

I strongly encourage web programmers to always enclose attribute values in quotes as good coding practice. That way they don’t get confused about when they need to use quotes and when they don’t.