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?
<html dir="rtl" lang="he">
<head>
<meta charset="utf-8">
...
</head>
...
</html>
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.
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
<html dir="rtl" lang="he">
not: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Does not work on "Chrome" and "Firefox" browsers.
<!DOCTYPE html>
<html lang="he">
<head>
<meta charset="utf-8">
...
</head>
Every HTML5 must contain a DOCTYPE
tag
Also, the lang
attribute is not limited to just the html
tag and it can be combined with multiple languages across the page
<!DOCTYPE html>
<html lang="he">
<head>
<meta charset="utf-8">
...
</head>
<body>
...
<section class="inline-translation" lang="he">
<h1>קטע תרגום</h1>
...
<h2>תרגומים מרובים</h2>
<div lang="en">Some content translated in English</div>
<div lang="es">Con elementos en otros idiomas <span class="tooltip" lang="jp">お知らせ</span></div>
</section>
<section class="inline-translation" lang="en">
<h1>Translation Excerpt</h1>
<div>Your content in another language</div>
</section>
<section class="inline-translation" lang="es">
<h1>Fragmento de Traducción</h1>
<div>Tu contenido en otro idioma</div>
</section>
<section class="inline-translation" lang="jp">
<h1>翻訳抜粋</h1>
<div>コンテンツを別の言語で</div>
</section>
Documentation:
© 2022 - 2025 — McMap. All rights reserved.