WEB-3Recommended
Declare UTF-8 first
Make <meta charset="utf-8"> the first element in <head>, so it falls inside the first 1024 bytes as the HTML standard requires. Send the same character set in the Content-Type header.
How to do it
Put <meta charset="utf-8"> before the title and any script. Set Content-Type: text/html; charset=utf-8 on the server. Email needs the same encoding, as Encode everything as UTF-8 says.
Examples
HTTP example
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
HTML example
<head>
<meta charset="utf-8">
<title>Page name · Example</title>
</head>
How to check
curl -s URL | head -c 1024 | grep -qi '<meta charset="utf-8">' succeeds. curl -sI URL shows Content-Type: text/html; charset=utf-8.
Sources
Related rules
- EML-4 Encode everything as UTF-8 in Email
- LOC-53 Keep text in UTF-8 at every layer in Localization
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/html-basics/meta-charset">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.