Generally, we recommend that you use HTML code that can pass standard validation unless you have to make concessions on performance optimization and file size control. HTML5 document type declaration is recommended for HTML standard document types :! DOCTYPEhtml. (We recommend that you use texthtml format ...,. Original article: Web Styleguide-Style guide to harmonize HTML, Javascript and CSS/SASS coding style
HTML Specification
Document Type
HTML5 document type statement is recommended:.
(Html in text/HTML format is recommended. Avoid using XHTML. XHTML and its attributes, such as application/xhtml + xml, have limited space for application support and Optimization in the browser ).
In HTML, it is better not to close tags with no content element [1]. For example, use
Rather
.
HTML Verification
Generally, we recommend that you use HTML code that can pass standard validation unless you have to make concessions on performance optimization and file size control.
Use tools such as W3C HTML validator for detection.
Standardized HTML is a significant quality baseline that shows technical requirements and limitations. It promotes better use of HTML.
Not recommended
- Test
- This is only a test.
Recommendation
-
- Test
- This is only a test.
Omit optional labels
The HTML5 specification specifies that HTML tags can be omitted. But in terms of readability, it is better not to do this in the development source file, because omitting tags may cause some problems.
Omitting some optional labels does reduce the page size, which is useful, especially for some large websites. To achieve this goal, we can compress the page at the end of development. In this step, these optional labels can be completely omitted.
Script Loading
For performance considerations, asynchronous Script Loading is critical. A script is placed inFor example