HTML Coding Conventions
Web developers are often unsure of the coding style and syntax to use in HTML. (Recommended learning: html tutorial)
Between 2000 and 2010, many web developers converted from HTML to XHTML.
With XHTML, developers are forced to write valid "well-formed" code.
HTML5 will be more relaxed when it comes to code validation.
With HTML5, you must create your own best practices, style guides, and coding conventions.
Smart and future-proof
Logical use of styles makes it easier for others to understand and use your HTML.
In the future, programs such as XML readers may need to read your HTML.
Use well-formed "XHTML-like" syntax to be smarter.
Note: Please always keep your styles smart, clean, pure, and well-formatted.
Please use the correct document type
Always declare the document type on the first line of the document:
<!DOCTYPE html>
If you consistently stick to lowercase tags, then You can use:
<!doctype html>
Please use lowercase element names
HTML5 allows mixed case letters in element names.
We recommend using lowercase element names:
Mixed case names are not good. Developers are accustomed to using lowercase names (such as in XHTML). Lowercase is cleaner and purer. Lowercase Easier to write
Not so good:
<SECTION> <p>This is a paragraph.</p> </SECTION>
Very bad:
<Section> <p>This is a paragraph.</p> </SECTION>
Not bad:
<section> <p>This is a paragraph.</p> </section>
The above is the detailed content of HTML coding conventions. For more information, please follow other related articles on the PHP Chinese website!