0

I've inherited some CSS that has the charset set at the top of the CSS like this:

@charset "UTF-8";

But is this still necessary if I have a tag in the head of the HTML page like this?

<meta charset="UTF-8" />

Does it do the same thing?

rsturim
  • 6,756
  • 15
  • 47
  • 59
  • Already answered here - http://stackoverflow.com/questions/2526033/why-specify-charset-utf-8-in-your-css-file – apnerve Apr 09 '12 at 14:07
  • 2
    I can't tell if you posted this because you forgot that you'd asked such a thing before, or because you're talking about HTML5 here. I don't think it's necessary to ask an HTML question again just for an HTML5-specific answer. – BoltClock Apr 09 '12 at 15:28

2 Answers2

0

Both do the same thing, they suggest the browser which charset was used when writing and saving the document.

It helps the browser decide which charset to display/parse the file in, so that it won't come out as gibberish.

If you don't use either one, the browser will take an educated guess and read the file in whatever charset it thinks most appropriate. Modern browser will generally do it easily.

I personally never used the CSS version, and my IDE adds the HTML version automatically, so I don't mind about it.

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
0

<meta charset="UTF-8" /> is for the HTML document while @charset is for the CSS document. None of them is necessary if the http header tells the browser that both the files are utf-8 encoded. These are only important if you view them locally.

apnerve
  • 4,740
  • 5
  • 29
  • 45