What are the new specifications in html5?

青灯夜游
Release: 2022-01-11 13:47:29
Original
2885 people have browsed it

The new specifications of html5 are: 1. Use two spaces to replace tab characters; 2. Nested elements should be indented once; 3. Add a doctype statement to the first line of each HTML page; 4. Specify the lang attribute for the HTML root element; 5. Specify the character encoding for the HTML page to ensure that the encoding of all documents is consistent, etc.

What are the new specifications in html5?

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

New specifications for HTML5

(1) Syntax

Use two spaces to Instead of tabs - this is the only way to guarantee a consistent presentation in all environments.

Nested elements should be indented once (two spaces)

For attribute definitions, make sure to use double quotes and never use single quotes.

Do not add a slash at the end of self-closing and (self-closing) elements. --The HTML5 specification clearly states that this is optional.

Do not omit the optional closing tag (for example: or )

HTML5 doctype: Add standard mode ( standard mode) to ensure consistent presentation in each browser.

<! DOCTYPE html>
Copy after login

(2) Language attribute

According to the HTML5 specification, it is strongly recommended to specify the lang attribute for the html root element, thereby setting the correct language for the document, which is helpful for speech Synthesis tools determine the pronunciation that should be used, translation tools help determine the rules that translators should follow, and so on.

(3) Character encoding

By declaring the character encoding, it can ensure that the browser can quickly and easily determine the rendering method of the page content. This can avoid Use character entity tags so that they are all consistent with the document encoding (usually UTF-8 encoding)

(4) Introduce CSS and JavaScript files

Introduce CSS and JavaScript files There is no need to specify the type attribute, text/css and text/javascript are their default values ​​respectively.

(5) Attribute order

HTML attributes should be arranged in the order given below to ensure the readability of the code

clss>id,name>data-''>src,for,type,href,value>title,alt,role.

(6) Boolean type attribute

Boolean attributes can be declared without assigning a value. The XHTML specification requires it to be assigned a value, but the HTML5 specification does not.

Related recommendations: "html video tutorial"

The above is the detailed content of What are the new specifications in html5?. For more information, please follow other related articles on 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!