EN
HTML - set web page encoding (e.g. UTF-8)
3 points
In this article, we would like to show you how to set encoding in HTML (e.g. UTF-8).
Quick solution (put it in the <head>
element):
xxxxxxxxxx
1
<meta charset="UTF-8">
Warning:
In practice it is necessary to set encoding on the server side to avoid bugs.
We can achieve it in 2 ways:
- by saving
*.html
files using proper encoding, e.g. UTF-8,- by adding specific header to the response, e.g.
Content-Type: text/html;charset=UTF-8
In this example, we present a simple full page template with the most commonly used charset - UTF-8
.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<meta charset="UTF-8">
5
<title>Title</title>
6
</head>
7
<body>
8
Page body here ...
9
</body>
10
</html>
In this example, we present the second approach, which is usingcontent-type
meta tag with charset
set to utf-8
.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<meta http-equiv="content-type" content="text/html; charset=utf-8">
5
<title>Title</title>
6
</head>
7
<body>
8
Page body here ...
9
</body>
10
</html>