Skip to main content
D
HTML
HTML Charset

HTML Charset

HTML charsets ensure the browser displays text correctly.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

A web browser needs to know the correct character set to render text properly. HTML5 recommends the UTF-8 character set. This modern set covers almost all languages and symbols globally.

Syntax

Syntax
1<!-- charset syntax -->
2<meta charset="UTF-8">

Example

Example
1<!-- this sets the charset -->
2<!DOCTYPE html>
3<html lang="en">
4  <head>
5    <meta charset="UTF-8">
6    <meta name="viewport" content="width=device-width, initial-scale=1.0">
7    <title>Charset</title>
8  </head>
9  <body>
10    <p>Text displays correctly.</p>
11  </body>
12</html>

Try it Yourself

Hands-on Practice
Modify the code below to see how it affects the output. This is the best way to learn!
Interactive Editor
1234567891011121314151617181920
Live Preview

Key Points

  • Charset defines the text encoding.
  • UTF-8 handles all global characters.
  • The meta tag sets the charset.
  • Missing charsets cause broken text symbols.

Up Next

Continue your journey with the next topic.

Go to HTML URL Encode