The semantics ofIt is used based on the initial meaning of the element (sometimes falsely referred to as the "label") when it is created. For example, use the P element to define a text paragraph, define a link anchor point with a element, and so on.
The use of HTML elements based on destination is significant for accessibility, code reuse, and code efficiency.
In simple terms, a rich semantic label is always clearer than a full-screen div!
Multimedia backtrackingFor media on the page, like pictures, videos, canvas animations, etc., make sure they have an alternative access interface. Image files We can use meaningful alternative text (ALT), video and audio files that we may add captions or subtitles to.
Providing alternative content is important for usability. Imagine how a blind user can know what a picture is, and if there is no alt. (The Alt attribute of the picture is not filled in, and a purely decorative picture can be used to do so:).
Type PropertyOmit the style sheet from the Type property on the script. Since the default type values in HTML5 are Text/css and Text/javascript, the Type property is generally negligible. Even in older versions of browsers it is safe to do so.
ID and Anchor PointIt's usually a good idea to add an ID to all header elements in the page. In this way, the URL of the page in the hash with the corresponding ID name, that is, the formation of a stroke, convenient to jump to the corresponding element location.
Formatting rulesAfter each block element, list element, and table element, add a new blank line and indent its descendant elements. Inline elements are written on one line, and block elements have lists and tables to be added to another line.
(It is acceptable to merge all elements into one row if the line breaks cause an unpredictable problem, and the format warning is better than the error warning).
HTML quotation marksUse double quotation marks ("") instead of single quotation marks (').
More practical than perfectTry to follow HTML standards and semantics, but not at the expense of practicality. Use as little complexity and as few tags as possible to solve the problem at all times.
Attribute OrderHTML attributes should appear in a specific order to ensure legibility.
1. Class
2. Id
3. Name
4, data-*
5, SRC, for, type, href, value, Max-length, max, Min, pattern
6, placeholder, title, alt
7, aria-*, role
8, required, ReadOnly, disabled
Class is designed for highly reusable components, and in theory they should be in the first place. IDs are more specific and should be used sparingly (for example, in-page bookmarks), so they are in second place.
If improper or supplement please advise!
Front-end Coding specification-HTML article