开发者

When the attribute value can remain unquoted in HTML5

开发者 https://www.devze.com 2023-02-19 19:22 出处:网络
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

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: alphan开发者_Go百科umeric 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?


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?


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

When the attribute value can remain unquoted in HTML5


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消