Search code examples
htmlutf-8character-encodingmetaw3c-validation

Error with UTF-8 character encoding in html file


I have looked and tried nearly everything but W3C validator keeps on giving me errors about the character encoding. I can't get my head around it hence I looked on the internet and with no luck I asked this question. Also my document is in HTML5.

Is there a way to overcome this?

Error given:

Validation Output: 4 Errors

Error The character encoding was not declared. Proceeding using windows-1252. ✉
Error Line 29, Column 23: A charset attribute on a meta element found after the first 512 bytes.

<meta charset="utf-8">

Error Line 29, Column 24: Changing character encoding utf-8 and reparsing.

<meta charset="utf-8">

Error Line 29, Column 24: Changing encoding at this point would need non-streamable behavior.

<meta charset="utf-8">

Solution

  • Look at the error message:

    A charset attribute on a meta element found after the first 512 bytes.

    Move the meta element with the charset attribute so it appears closer to the beginning of the document. The first child element of the head element is a good place for it.