Get the App
SLTechnology News&Howtos  ›  Development  › 

In HTML, what is the use of the declaration?

Shulou Source: shulou.com Published: 2022-06-01 06:33:16 11月14日 Update

This article mainly shows you "what is the use of statements in HTML", the content is simple and clear, and I hope it can help you solve your doubts. Let me lead you to study and study this article "what is the use of statements in HTML?"

Example

Document title

The contents of the document.

Label definition and instructions for use

The declaration is at the front of the document, before the tag.

The declaration is not a HTML tag; it is used to tell Web browsers which version of HTML the page uses.

In HTML 4.01, the declaration refers to DTD (document type declaration) because HTML 4.01 is based on SGML (Standard Generalized Markup Language Standard Universal markup language). DTD specifies the rules of the markup language to ensure that browsers render content correctly.

HTML5 is not based on SGML, so a reference to DTD is not required.

Tip: always add a declaration to your HTML document to make sure that the browser knows the document type in advance.

Differences between HTML 4.01 and HTML5

HTML 4.01 specifies three different declarations: Strict, Transitional, and Frameset. Only one is specified in HTML5:

HTML elements and Doctypes

See the HTML element and the legal Doctype to see which Doctype each HTML element appears in.

Tips and comments

Note: the tag does not end the tag.

Tip: the declaration is case-insensitive.

Tip: use W3C validation to check that you have written a legitimate HTML / XHTML document with the correct DTD!

Common DOCTYPE statements

HTML 5

HTML 4.01 Strict

This DTD contains all HTML elements and attributes, but does not include imagery or outdated elements (such as font). Framesets are not allowed.

HTML 4.01 Transitional

This DTD contains all HTML elements and attributes, including representational or outdated elements (such as font). Framesets are not allowed.

Tags: Element content document frame tag obsolete attribute representation hint same standard browser article language browsing legal tag format comment type Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Huawei Xiaomi Apple OPPO Reno