Skip to main content

What does <meta charset="UTF-8"> do?

The <meta charset="UTF-8"> tag tells the browser what encoding the HTML document is written in, so it correctly displays all characters: letters, digits, symbols, spaces, emoji, and so on.


1. What is encoding

Encoding is the way a computer stores and understands text characters. Each character (letter, digit, symbol) has its own numeric code.

  • Older sites often used encodings like Windows-1251 (for Cyrillic languages) or ISO-8859-1 (for Western languages).
  • The modern standard is UTF-8, which supports all languages of the world, including Cyrillic, Arabic, Chinese, and even emoji.

2. What meta charset="UTF-8" does

When the browser opens a page, the first thing it reads is the tag:

html
<meta charset="UTF-8">

and understands:

"All characters in this file must be interpreted using UTF-8 encoding."

Thanks to this, text like:

html
<h1>Hello, world!</h1>

displays correctly, instead of as "киÑилиÑÑ".


3. Why it's important to place this tag at the beginning of <head>

The browser reads HTML sequentially from top to bottom. If the encoding is not specified immediately, it may manage to "read" a few characters in the wrong system and display them as garbled text.

Correct:

html
<head> <meta charset="UTF-8"> <title>Home page</title> </head>

Incorrect:

html
<head> <title>Home page</title> <meta charset="UTF-8"> </head>

4. Why specifically UTF-8

  • Universal: works with any language.
  • Supports special characters, emoji, mathematical symbols.
  • Compatible with most servers and systems.
  • It is the official HTML5 standard.

Summary:

ParameterValue
Tag<meta charset="UTF-8">
PurposeTells the browser which encoding to use
What it doesGuarantees correct text display
Why it mattersWithout it: garbled text and character errors
HTML5 standardRecommends UTF-8 specifically

In simple terms: <meta charset="UTF-8"> tells the browser:

"This page is written in a universal encoding. Show all characters correctly."

Without it, Cyrillic text can turn into unreadable characters.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.