http://codeguide.bootcss.com/#html-syntax Reference link
Attribute Order
HTML attributes should be arranged in the order given below to ensure readability of the code.
- Class
- ID, name
- data-*
- SRC, for, type, href
- Title, Alt
- aria-*, role
Class is used to identify highly reusable components and should therefore be ranked first. ID is used to identify specific components and should be used with caution (for example, bookmarks within a page), so it is ranked second.
Declaration Order
The related attribute declarations should be grouped into groups and arranged in the following order:
- Positioning
- Box model
- Typographic
- Visual
Because positioning (positioning) removes elements from the normal flow of documents and also overrides the box model-related styles, it is ranked first. The box model is ranked second because it determines the size and position of the component.
Other properties only affect the interior of the component (inside) or do not affect the first two sets of properties, so it is followed.
Do not use @import
@import instructions are much slower than the <link> tag, not only increasing the number of requests, but also causing unforeseen problems. There are several alternatives to this approach:
- Use multiple <link> elements
- Compile multiple CSS files into a single file by using a CSS preprocessor similar to Sass or less
- CSS file merging provided through Rails, Jekyll, or other systems
Editor configuration
Set up your editor according to the following configuration to avoid common code inconsistencies and differences:
- Use two spaces instead of tabs (Soft-tab is a space for tab characters).
- When you save the file, remove the trailing white space character.
- Set the file encoding to UTF-8.
- Add a blank line at the end of the file.
HTML encoding and CSS encoding will encounter the question