htmlcharacter-encoding

What is the default character encoding for HTML?


For some reason, the plain text character on the html side is being displayed as –. The only thing I can think that would be attributed to this is the character encoding. My guess is that it's UTF-8, but I am not sure how I am getting the weird characters. Is there an explanation?

What I mean by default is if the charset isn't specified.


Solution

  • The !DOCTYPE doesn't set a character encoding; the meta element together with the (newly standardized) charset attribute does. If it's absent, I'm not entirely sure how the browser determines the encoding.

    I believe the problem you're having though is that your page is saved in one encoding and served in another.

    Just make sure you set <meta charset="utf8"/> and make sure your document is in fact UTF-8, and it should work.