简体   繁体   English

CSS中引用和不引用属性选择器之间的区别

[英]The difference between quoted and unquoted attribute selector in CSS

I was wondering what is the difference between quoted and unquoted attributes in css selectors and does that have any effect on performance. 我想知道css选择器中引用和不引用属性之间的区别是什么,这对性能有什么影响。

input[type="text"]

/ /

input[type=text]

Thanks in advance 提前致谢

The above are the same. 以上都是一样的。 The quotes are optional for identifiers , but must be used when it is a string . 引号对于标识符是可选的,但必须在它是字符串时使用

Some common examples of being a string include: 作为字符串的一些常见示例包括:

  • Containing a space ( 包含空间( )
  • Beginning with a digit ( 0-9 ) 以数字开头( 0-9
  • Containing a hyphen after a digit 在数字后面包含连字符

Here's the full spec of an identifier : 是标识符的完整规范

In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); 在CSS中,标识符(包括选择器中的元素名称,类和ID)只能包含字符[a-zA-Z0-9]和ISO 10646字符U + 00A0及更高,加上连字符( - )和下划线( _); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. 它们不能以数字,两个连字符或连字符后跟数字开头。 Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). 标识符还可以包含转义字符和任何ISO 10646字符作为数字代码(请参阅下一项)。 For instance, the identifier "B&W?" 例如,标识符“B&W?” may be written as "B\\&W\\?" 可以写成“B \\&W \\?” or "B\\26 W\\3F". 或“B \\ 26 W \\ 3F”。


Further reading: http://www.w3.org/TR/css3-selectors/#attribute-selectors 进一步阅读: http//www.w3.org/TR/css3-selectors/#attribute-selectors

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM