Kanbritech Learn logo
HTML HTML Tutorial 45h track

HTML Charsets

Write the character encoding declaration for a UTF-8 document.

Understand the topic

A character encoding maps stored bytes to characters. UTF-8 supports a broad range of languages and is the normal choice for modern web pages. Save the file as UTF-8 and declare it early using meta charset. The server should also send a matching charset in Content-Type. A declaration cannot repair a file saved using the wrong encoding.

Worked example

<!doctype html>
<html lang="en"><head><meta charset="utf-8"><title>Names</title></head>
<body><p>Names from every language belong on the web.</p></body></html>

lang describes the language of the content, while charset describes how the bytes are decoded. They solve different problems.

Practice

Write the character encoding declaration for a UTF-8 document.

Show a suggested answer
<meta charset="utf-8">

Common mistake

Garbled characters often indicate a mismatch between file encoding, server headers, and document metadata. Check all three.

HTML documentation

Try Coding

Result