What is the correct way of declaring a HTML5 page to be in Hebrew, RTL and utf-8 encoded? I haven't done it in a while, but I remember that in HTML4 it involved 3 or 4 tags and attributes that seemed redundant. Is it still the same?
Asked
Active
Viewed 1.3k times
4 Answers
10
<html dir="rtl" lang="he">
<head>
<meta charset="utf-8">
...
</head>
...
</html>

ChuckE
- 5,610
- 4
- 31
- 59
-
5would like to add that it is very important that the character encoding meta tag is the first meta tag from your document. Imagine you declare the document title before with hebrew characters. Some tools used to fetch and parse the documents will parse the title of your document in a wrong encoding, resulting in string-handling inconsistencies. This is a problem which english doesn't suffer from. – ChuckE Oct 11 '12 at 12:44
9
You need the following:
- A
<!doctype html>
to indicate your page is HTML5. - An
<HTML>
tag with the following attributes:dir
=
"rtl"
lang="he"
Note: you may omit the"
, or use'
instead.
- A
<meta>
tag to declare the character encoding. You can choose one of the following:<meta charset="UTF-8">
Note: you may omit the"
, or use'
instead.<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
This is the "legacy" way of declaring character encoding. It's still allowed within HTML5, but all modern browsers support the first variant so there is no need for this.
Note: you may omit the"
for thehttp-equiv
attribute, or use'
instead for all attributes.- If the browser encounters an UTF-8 byte order mark, it will treat an HTML5 file as UTF-8. This happens regardless of any character encoding declared using
meta
tags.
None of the tags, attributes and attribute values used here, or the DOCTYPE
, are case sensitive.
Note: if the browser encounters a character encoding declaration, it will re-parse the document from the start using the specified encoding. You can put your encoding inside a Content-Type
HTTP header so this won't be a problem.
Note also that the browser will only look for a character encoding declaration in the first 1024 bytes of a document.

user2428118
- 7,935
- 4
- 45
- 72
-
2About those possibly omitted quotes: If you write a parser you should expect that quotes may be missing. If you write a document or a document generator, you really should include the quotes. – Rasmus Kaj Apr 02 '13 at 19:40
2
You need these to create a HTML5 page with language as hebrew, direction as RTL, and utf-8 encoded
<!DOCTYPE html>
For declaring it as a HTML5 page
<html dir="rtl" lang="he">
For direction and language
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
For utf-8

Mr. Alien
- 153,751
- 34
- 298
- 278