38

/在 html/css 中的类名中使用是否有效?

// html
<div class="/10"></div>

// css
./10{ float:left; }
4

1 回答 1

56

You can use most unicode characters in both the class and id attributes in HTML.

This means you can indeed use / in a classname in HTML, but you will run into problems when trying to select it with ./10 in CSS, as you've likely found out yourself. If you escape the slash, you're golden! :)

.\/10 {
    float:left;
}

Check out http://mathiasbynens.be/notes/html5-id-class and http://mathiasbynens.be/notes/css-escapes

于 2013-08-28T10:37:53.157 回答