当属性值可以在HTML5中保持不引用时 [英] When the attribute value can remain unquoted in HTML5
问题描述
何时可以在HTML5中将属性值保留为无引号?
When the attribute value can remain unquoted in HTML5?
HTML4.01是SGML应用程序.因此,在HTML4中,如果值中唯一使用的字符是当前声明为名称字符的字符,则可以省略引号:字母数字字符,句号,-,:,_.
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, -, :, _.
好,摘自W3C工作草案(2011年1月13日):
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 >.
但是,如果我在属性值中输入除字母数字字符,句号,-,:,_之外的任何其他字符,并保留其未加引号的validateator.w3.org不会将我的html文档验证为有效的HTML5文档.
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.
因此问题仍然存在.是HTML5工作草案的错误还是在validate.w3.org上的错误?
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.
尝试一下
<!DOCTYPE html>
<title>test</title>
<div class=%test$></div>
在 http://validator.w3.org/#validate_by_input
验证器对%和$字符都满意.那您到底要测试什么?
The validator is happy with both the % and $ characters. So what exactly are you testing?
这篇关于当属性值可以在HTML5中保持不引用时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!