Special characters in CSS selectors [closed]

≯℡__Kan透↙ 提交于 2019-11-28 04:05:29

问题


What are those? So I can escape them..


回答1:


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+00A1 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, 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).code (see next item).

http://www.w3.org/TR/CSS21/syndata.html#characters




回答2:


Normally, you wouldn't need to escape any special characters in CSS. This is because most CSS selector characters (., >, +, ~, #, :, etc) are not valid in id attributes or tag names, and they are rarely used in class names.

The only notable exception is a namespaced element in the form <ns:tagName>, which is more commonly seen in Internet Explorer. To target those elements, you can escape the : character. For example, VML objects have their behavior defined as follows:

v\:* { behavior: url(#default#vml); }


来源:https://stackoverflow.com/questions/4132793/special-characters-in-css-selectors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!