How to declare the character encoding
Declaring UTF-8 in the first 1024 bytes stops browsers from guessing and prevents garbled characters.
Step by step, with screenshots: HTML validation errors: which ones matter and which are noise →
Check your own site
Runs this check and the other 186, free, in about 45 seconds.
What a passing site looks like
- Character encoding is declared earlywarning · −1 ptseffort S
Character encoding is not declared early enough
Why it matters. Browsers need to know the encoding before they read the text. When it is missing or declared late, accented letters such as č, ć and š can appear as garbage and the page re-renders.
- Put <meta charset="utf-8"> as the first element inside <head>, within the first 1024 bytes of the document.
- Or send it in the response header: Content-Type: text/html; charset=utf-8.