CSS输入[type ="type"]需要引用?

Per*_*cat 3 css quotes css3

我一直认为CSS输入[类型]选择器需要引号来指定类型,例如:

input[type="email"], input[type="text"]
Run Code Online (Sandbox Code Playgroud)

现在我下载了几个样式的复选框和CSS报告:

input[type=checkbox] {
     display:none;
}
Run Code Online (Sandbox Code Playgroud)

报价是否需要或者是否与它们相同?

use*_*740 6

不,根据CSS语法规则不需要引号.

规则有点混乱,但这是相关的生产.请注意该值如何可以是标识符(未加引号的类似字的值)或带引号的字符串.

attrib
  : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S*
    [ IDENT | STRING ] S* ]? ']'
Run Code Online (Sandbox Code Playgroud)

和相关的令牌:

ident       -?{nmstart}{nmchar}*
nmstart     [_a-z]|{nonascii}|{escape}
nmchar      [_a-z0-9-]|{nonascii}|{escape}

string      {string1}|{string2}
string1     \"([^\n\r\f\\"]|\\{nl}|{escape})*\"
string2     \'([^\n\r\f\\']|\\{nl}|{escape})*\'
Run Code Online (Sandbox Code Playgroud)

精明的读者可能已经注意到在标识符字符中允许使用"nonascii":在ASCII平面之外,技术上允许所有Unicode字符在标识符中.然而,从实际的角度来看,除了"琐碎"的案例外,我建议引用任何内容.