In the previous article, we mentioned the software used to compile CSS files. Today, let's look at some introductions: how can we efficiently perform CSS encoding?
What software should I use for CSS webpage layout development?
One of the advantages of CSS is that it can reduce the page size and shorten the download time, not only the loading of the homepage, but also after the style sheet is cached, the loading of subsequent pages is also accelerated. This is true, but the shortening of the loading time on the homepage is almost invisible because the CSS code is too long.
Okay, now everything is different. Learn how to use CSS coding efficiently so that you can minimize the size of the style sheet. Naturally, you may not see any amazing changes, but small bytes are also important for large websites.
There are many ways to reduce the code length, including shorthand properties, multiple declarations, default values, and inheritance ), and white space ).
Note attributes
Zeroing page margins mentioned a set of such note attributes, but there are more.
Note attributes include:
Font (control "font-size", "font-weight", "line-height", etc.) background (control the background, placement location, repeat times, and so on of elements)
List-style (set the attribute of the "origin" at the front of the list element)
Margin (defines the width of the margin (margin) on each side of the box)
Border (defines the attributes of the box boundary (border), including many tracing attributes related to the boundary) padding (defines the width of the padding on each side of the box)
The above project is linked to the relevant chapter of W3C CSS 2 specification.
For example, the font attribute is used to set the simple attributes of font-style, font-variant, font-weight, font-size, line-height, and font-family at the same time. Of course, not all of them must be written in the simplified attributes. Once a certain attribute is ignored in the summary attribute, all missing attributes will be set as their initial values, as mentioned in the font property section in W3C standards. To control many font-related attributes, you can use this note attribute to save a large number of bytes in the style sheet.