What's the issue?
Your page has a charset declaration, but it's not the first element inside the <head> tag. The HTML specification recommends that the charset meta tag appears within the first 1024 bytes of the document, and best practice is to make it the very first tag.
Why does order matter?
Browser parsing
- The browser needs to know the character encoding before it can correctly parse any text content
- If the charset appears after other elements (like
<title>), the browser may have already misinterpreted characters - This can cause a re-parse of the document, leading to a visible flash
Security
- The HTML5 spec mandates that charset must be within the first 1024 bytes for security reasons
- Late charset declarations can be exploited for encoding-based attacks (UTF-7 XSS)
Correct rendering
- Non-ASCII characters in
<title>or other early meta tags may be garbled if the charset hasn't been declared yet
How to fix it
Move the charset declaration to be the very first element inside <head>:
<head>
<meta charset="UTF-8" />
<title>Your Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- other meta tags after -->
</head>Recommended head order
<meta charset="UTF-8" />— Must be first<meta name="viewport" ...>— Early for proper rendering<title>— Page title<meta name="description" ...>— SEO description- Other meta tags (OG, Twitter, etc.)
- CSS and other resources
Common mistakes
<!-- Bad: title before charset -->
<head>
<title>My Page with Spëcial Chàracters</title>
<meta charset="UTF-8" />
</head>
<!-- Good: charset first -->
<head>
<meta charset="UTF-8" />
<title>My Page with Spëcial Chàracters</title>
</head>