0

I looked for what characters are valid in CSS style names and found a few questions/posts, such as:

Which characters are valid in CSS class names/selectors?

Can I safely use unicode characters (e.g. accents) in CSS class names or ids?

https://css-tricks.com/unicode-class-names/

All these suggest accented and other unicode characters can be used in css style names. However I found the begavior is different in Safari and other browsers. e.g. with characters such as Ø Ö Ä ñ in css style names, Safari does not apply the style, but chrome, firfox, edge do.

Then I checked these style names with CSS-Validator, and it does give error.

So can't we use these characters normally, without unicode escaping? Are only ascii characters valid in css style names?

Community
  • 1
  • 1
Nitesh
  • 2,321
  • 1
  • 23
  • 38

2 Answers2

0


Quick answer

You should always use UTF-8 as the character encoding of your style sheets and your HTML pages, and declare that encoding in your HTML. If you do that, there is no need to declare the encoding of your style sheet.

Other approaches are only needed if your style sheet contains non-ASCII characters and, for some reason, you can't rely on the encoding of the HTML and the associated style sheet to be the same. In this case you should use @charset or HTTP headers to declare the encoding. (If your HTML and CSS files use the same encoding, the latest versions of major browsers will apply the encoding of the HTML file to the CSS stylesheet.)

Refer : https://www.w3.org/International/questions/qa-css-charset

4dgaurav
  • 10,721
  • 4
  • 27
  • 55
0

I can safely say that, Yes. Even in html creation programs, if you give an object a name contains non-ascii character, the HTML wont work correctly if you deploy it to a location.

I am Turkish, we have some non-ASCII characters. For that reason we see a lot of people making that mistake. It is never good/ok to use those characters.

Demeter Dimitri
  • 563
  • 6
  • 16