Andy
Andy

Reputation: 633

When the attribute value can remain unquoted in HTML5

When the attribute value can remain unquoted in HTML5?

HTML4.01 was a SGML application. So in HTML4 quotes can be omitted if the only characters used in the value are ones currently declared as name characters: alphanumeric character, full stop, -, :, _.

Well, from the W3C working draft (13 January 2011):

The attribute value can remain unquoted if it doesn't contain spaces or any of " ' ` = < or >.

But if I put in the attribute value any other character than alphanumeric character, full stop, -, :, _ and remain it unquoted validator.w3.org doesn't validate my html document as valid HTML5 document.

So the question is still open. Is it a mistake of HTML5 working draft or is it a mistake on validate.w3.org?

Upvotes: 4

Views: 1820

Answers (3)

Mathias Bynens
Mathias Bynens

Reputation: 149704

This article on unquoted attribute values in HTML and CSS will answer your question. There’s also a tool: http://mothereff.in/unquoted-attributes

Upvotes: 1

Kevin Ji
Kevin Ji

Reputation: 10499

Unless you are sticking in the xmlns attribute to your html element, rendering your document as XHTML 5 (the XML serialization of HTML 5), using unquoted values with appropriate characters validates as proper HTML 5.

Upvotes: 0

Alohci
Alohci

Reputation: 83006

No, the working draft is fine and the validator is working correctly.

Try this

<!DOCTYPE html>
<title>test</title>
<div class=%test$></div>

at http://validator.w3.org/#validate_by_input

The validator is happy with both the % and $ characters. So what exactly are you testing?

Upvotes: 1

Related Questions