Adding Padding Around an Element
Padding is just what it sounds like: extra space around the contents of an element but inside the border. Think of Santa Claus' bellynicely padded, while being held in by his belt (the border). You can change the padding's thickness, but not its color or texture. (Margins are Santa's personal space.)
To add padding around an element:
Type padding: x, where x is the amount of desired space to be added, expressed in units (10px) or as a percentage of the width of the parent element (20%).
Tips
As with the margin property, if you use one value, the specified padding is applied to all four sides equally. If you use two values, the first value applies to the top and bottom and the second value applies to the right and left. If you use three values, the first applies to the top, the second to the right and left, and the third to the bottom. If you use four values, they are applied to the top, right, bottom, and left, in clockwise order. You can also add one of the following suffixes to the padding property to apply padding to a single side: -top, -bottom, -left, or -right. There should be no space between the word padding and the suffix (e.g., padding-right: 1em).
Padding is not inherited. Use percentages or ems to create liquid layouts that expand or contract depending on the visitor's monitor. The space after the colon is optional. There is never a space between the number and the unit.
|