HTML5 coding standards

Use the correct document type

The document type declaration is located on the first line of the HTML document:

If you want it to be the same as other tags To use lowercase, you can use the following code:


Use lowercase element names

HTML5 element names can be used Uppercase and lowercase letters.

Recommended to use lowercase letters:

Mixing upper and lower case style is very bad.

Developers typically use lowercase (similar to XHTML).

The lowercase style looks more refreshing.

Lowercase letters are easy to write.


This is a paragraph.



Close all HTML elements

In HTML5, you don’t have to close all elements ( such as the

element), but we recommend adding a closing tag to each element.


This is a paragraph.


This is a paragraph.



Close empty HTML elements

In HTML5, empty HTML elements are not necessarily To close:

We can write like this:

We can also write like this:

< ;meta charset="utf-8" />

The slash (/) is required in XHTML and XML.

It's good to use this style if you expect XML software to use your page.


Use lowercase attribute names

HTML5 attribute names allow the use of uppercase and lowercase letters.

We recommend using lowercase letters for attribute names:

It is a very bad habit to use uppercase and lowercase letters at the same time.

Developers typically use lowercase (similar to XHTML).

The lowercase style looks more refreshing.

Lowercase letters are easy to write.

submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!