Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forward slash in class name [duplicate]

Is it valid to use / in a class name in html/css?

// html <div class="/10"></div>  // css ./10{ float:left; } 
like image 928
Adam Halasz Avatar asked Aug 28 '13 10:08

Adam Halasz


1 Answers

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

like image 62
xec Avatar answered Sep 21 '22 16:09

xec