Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 page language, direction and encoding

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?

like image 929
Baruch Avatar asked Oct 11 '12 12:10

Baruch


3 Answers

<html dir="rtl" lang="he">
  <head>
    <meta charset="utf-8">
     ...
    </head>
  ...
</html>
like image 93
ChuckE Avatar answered Oct 20 '22 21:10

ChuckE


You need the following:

  1. A <!doctype html> to indicate your page is HTML5.
  2. An <HTML> tag with the following attributes:
    • dir="rtl"
    • lang="he"
      Note: you may omit the ", or use ' instead.
  3. 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 the http-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.

like image 39
user2428118 Avatar answered Oct 20 '22 22:10

user2428118


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

like image 44
Mr. Alien Avatar answered Oct 20 '22 20:10

Mr. Alien