Set an Element's Padding
By Stephen Bucaro
Padding is the space between the element's content and the element's border. Use the padding
property to set an elements padding.
Padding set to 12 pixels
<span style="border-style: solid; border-width: 1px; background-color: #ffff00; padding: 12px;">Padding set to 12 pixels</span>
Use the padding-top property to set just the top padding:
Top padding set to 12 pixels
<span style="border-style: solid; border-width: 1px; background-color: #ffff00; padding-top: 12px;">Top padding set to 12 pixels</span>
Use the padding-right property to set just the right side padding:
Right padding set to 24 pixels
<span style="border-style: solid; border-width: 1px; background-color: #ffff00; padding-right: 24px;">Right padding set to 24 pixels</span>
Use the padding-bottom property to set just the bottom padding:
Bottom padding set to 12 pixels
<span style="border-style: solid; border-width: 1px; background-color: #ffff00; padding-bottom: 12px;">Bottom padding set to 12 pixels</span>
Use the padding-left property to set just the left side padding:
Left padding set to 24 pixels
<span style="border-style: solid; border-width: 1px; background-color: #ffff00; padding-left: 24px;">Left padding set to 24 pixels</span>
Use a shortcut to set the padding for all four sides to different values
padding:10px 20px 5px 25px;
<span style="border-style: solid; border-width: 1px; background-color: #ffff00; padding: 10px 20px 5px 25px;">padding:10px 20px 5px 25px;</span>
• Note that the order of values for the shortcut is not the standard left, top, right, bottom. Instead it's: top, right, bottom, left.
More CSS Quick Reference: • Set the Border Properties • Set List Bullets Position • Set the Font Style • Set the Border Color • Context selectors • Set the Background Properties • Set the Text Case • Indent the First Line of Text • Set the Font Slant • Set The Cursor Style
|