Dichiarazione HTML <!DOCTYPE>


Esempio

<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>

<body>
The content of the document......
</body>

</html>

Definizione e utilizzo

Tutti i documenti HTML devono iniziare con una <!DOCTYPE>dichiarazione.

La dichiarazione non è un tag HTML. È una "informazione" per il browser sul tipo di documento da aspettarsi.

In HTML 5, la dichiarazione è semplice:

<!DOCTYPE html>

Supporto browser

Element
<!DOCTYPE> Yes Yes Yes Yes Yes

Documenti HTML precedenti

Nei documenti più vecchi (HTML 4 o XHTML), la dichiarazione è più complicata perché la dichiarazione deve fare riferimento a una DTD (Document Type Definition).

HTML 4.01:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

XHTML 1.1:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Elementi HTML e Doctypes

Guarda la nostra tabella di tutti gli elementi HTML e in quale Doctype appare ogni elemento .


Suggerimenti e note

Suggerimento: la <!DOCTYPE>dichiarazione NON fa distinzione tra maiuscole e minuscole.

Esempi

<!DOCTYPE html>
<!DocType html>
<!Doctype html>
<!doctype html>