Il tag HTML <doctype>



Descrizione

Il tag HTML <doctype> serve ad indicare quale versione di HTML utilizza il documento. Fa riferimento al DocumentType Declaration (DTD).

NOTA: Il tag <!DOCTYPE> non ha un tag finale!.

Esempio

<!DOCTYPE html>
<html>
<head>
<title>HTML doctype Tag</title>
</head>
<body>
<p>doctype declaration <doctype> is mentioned at the starting of every HTML document.</p>
</body>
</html>

Produrrà il seguente risultato:

doctype declaration <doctype> is mentioned at the starting of every HTML document.

Dichiarazioni

HTML 4.01 ha 3 possibili doctypes: HTML 4 Strict, HTML 4 Transitional, e HTML 4 Frameset. Ogni documento HTML che creerete dovrebbe avere una fra queste tre dichiarazioni.

HTML 4 Strict

Questa dichiarazione include tutti gli elementi HTML ad eccezione di quelli che sono stati deprecati, e quelli che appaiono nei documenti frameset.

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

HTML 4 Transitional

Questa dichiarazione include tutti gli elementi HTML compresi quelli deprecati.

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

HTML 4 Frameset

Questa dichiarazione include sia tutti gli elementi HTML compresi definiti nel DTD che quelli nel framed document.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
	"https://www.w3.org/TR/html4/frameset.dtd">

Dichiarazione HTML 5

In HTML5 c'รจ solo una dichiarazione:

<!DOCTYPE html>

Compatibilità Browser

ChromeFirefoxIEOperaSafariAndroid
SiSiSiSiSiSi
html_tags_reference.htm
Advertisements