DOCTYPE always ignored

高洛峰
Release: 2017-02-15 13:58:19
Original
1518 people have browsed it

Explanation of terms

  • DTD: Document Type Definition Document type definition

  • ##SGML: Standard Generalized Markup Language Standard Generalized Markup Language.

SGML is a very powerful but complex markup language, from which HTML and XML are derived.

Why is there a "!"?

The statement is not an HTML tag;

's location ?

The statement must be located on the first line of the HTML document, before the tag

What is the role of?

Tell the browser what standard to use to parse this document. A non-existent or incorrectly formatted DOCTYPE will cause the document to be rendered in compatibility mode.

What is the difference between HTML4.01 and HTML5 DOCTYPE?

HTML5 has only one declaration:

HTML4.01 has three declarations: strict, transitional, frameset

HTML4.01 is based on SGML and needs to reference the DTD , tells the browser what document type to use.

HTML5 is not based on SGML and does not need to reference DTD, but it needs to use DOCTYPE to standardize browser behavior.

SGML is the most powerful and ancient. XML is a subset of SGML. HTML originally tried to be a subset of SGML, but HTML 4 did not strictly conform to the standards of SGML before. Later came HTML4, XHTML (HTML that conforms to the XML standard), both of which comply with the requirements of SGML.

When the W3C formulated the HTML5 standard, it hoped to get rid of some useless functions and declarations of SGML and continue the style of HTML4 rather than the strict style of XHTML.

Rendering mode of the page

The rendering mode of the page triggers compatibility mode and standard mode respectively depending on whether DOCTYPE is declared.

document.compatMode can return the compatibility mode of the current page:

document.compatMode
> CSS1Compat  //标准模式
> BackCompat  //怪异模式、兼容模式
Copy after login
Standard mode page layout and JS running mode are all run at the highest standard supported by the browser.

In compatibility mode, pages are displayed in a loosely backwards compatible manner, simulating the behavior of older browsers to prevent the site from not working.

For more DOCTYPE related articles that are always ignored, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!