Border margin and supplemental white padding (according to the translation conventions of Chinese publishing houses, margin is translated into border, and padding is translated into supplementary White, and the translator translates according to the habit. However, the translator believes that, when margin is translated into an outer margin, padding is translated into an inner margin, which is more straightforward and image-oriented. You can adapt to these two different translations based on your habits. Is the two most common attributes used to separate elements. The boundary is the distance outside the element, while the padding is the internal distance of the element.
The improved code for h2 is as follows:
The code is as follows: |
Copy code |
H2 { Font-size: 1.5em; Background-color: # ccc; Margin: 1em; Padding: 3em; }
|
You can see that there is a character width on the outer side of the Level 2 title, which is very bloated because there are three character widths inside the Level 2 title.
You can set different values on the four sides of an element. Margin-top, margin-right, margin-bottom, margin-left, padding-top, padding-right, padding-bottom, and padding-left are attributes that do not need to be explained. meaning ).