Tailwind CSS uses classes like w-1/2
that contain the slash /
character. According to this answer, slashes aren't allowed inside of class names. Why does it still work? What spec are the browser vendors actually implementing?
Asked
Active
Viewed 675 times
-1

Tobias Mühl
- 1,788
- 1
- 18
- 30
-
1This answer is quite old and if you read a little bit further people say that slash is totally valid symbol. Some in depth article for example https://mathiasbynens.be/notes/css-escapes, quite recent csswg discussion https://github.com/w3c/csswg-drafts/issues/7129#issuecomment-1069331981 – Danila Aug 10 '22 at 12:02
-
You're muddling HTML and CSS. A class name, even if it's a tailwind class name, is HTML, not CSS, and HTML attribute value rules apply. There, a `/` is a normal character. On the other hand, in a CSS selector the `/` must be escaped, but tailwind is hiding that detail behind its abstraction. – Alohci Aug 10 '22 at 12:38
1 Answers
0
You can use tailwind classes in class names. Only omit the \
slash and use left-1/4
instead of .left-1\ /4
. The answer you are referring is very old

Imran Malik
- 31
- 4