Home > Web Front-end > HTML Tutorial > HTML coding conventions

HTML coding conventions

(*-*)浩
Release: 2019-10-28 15:25:16
Original
2786 people have browsed it

HTML coding conventions

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>
Copy after login

If you consistently stick to lowercase tags, then You can use:

<!doctype html>
Copy after login

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>
Copy after login

Very bad:

<Section> 
  <p>This is a paragraph.</p>
</SECTION>
Copy after login

Not bad:

<section> 
  <p>This is a paragraph.</p>
</section>
Copy after login

The above is the detailed content of HTML coding conventions. 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