HTML Charset
HTML charset, or character set, refers to the encoding used to represent text in an HTML document. It defines how characters are mapped to bytes, which affects how text is displayed and interpreted by browsers.
Common Charset Encodings:
-
UTF-8: The most widely used character encoding. It can represent any character in the Unicode standard and is backward-compatible with ASCII. It supports a wide range of characters from various languages and is ideal for multilingual web pages.
-
ISO-8859-1 (Latin-1): An older encoding that covers Western European languages. It supports characters like ñ and ü but doesn't include many symbols and characters from other languages.
-
ASCII: A very basic encoding that includes only 128 characters, which covers standard English letters, digits, and some punctuation marks. It's limited compared to UTF-8.
Setting Charset in HTML
To specify the character encoding for an HTML document, you use the <meta>
tag within the <head>
section:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Here, <meta charset="UTF-8">
tells the browser to use UTF-8 encoding to interpret the document. This ensures that text is displayed correctly, regardless of the characters used.
At Online Learner, we're on a mission to ignite a passion for learning and empower individuals to reach their full potential. Founded by a team of dedicated educators and industry experts, our platform is designed to provide accessible and engaging educational resources for learners of all ages and backgrounds.
Copyright 2023-2025 © All rights reserved.