CSS - Cascading Style Sheets

An Interactive How To Code CSS Tutorial for Beginners

Learn faster with my new interactive CSS course for iPad!

CSS: CSS Padding

Our Hosting Partners:

65% off at FatCow!

iPage Hosting $4.25/mo
1&1 Hosting $6.99/mo

Free Domain Name
If you Order Today!

Our CSS Style topics:


CSS Code Tutorial Chapters:

  1. Introduction
  2. Basics of CSS
  3. All About Selectors
  4. Background and Color
  5. Fonts and Text
  6. Links
  7. Lists
  8. Margin
  9. Padding
  10. Border
  11. Good CSS Design
  12. Resources

visit our other tutorials:

web design tutorial
html code tutorial


Cascading Style Sheets: an Interactive Tutorial

CSS Padding

If you are reading this for a class and your professor wants you to summarize any two chapters, I'd definitely pair this one with the margin chapter!


padding: is just like a margin, except it's the white space between the margin (and border) and the actual content. Unlike margin, which inherits the background color of whatever is around the margin, padding uses the background-color specified for whatever it is padding (e.g. the "content content").

Padding is just as simple as margin to use, and it follows the same format (A B C and D as pictured). If you want a paragraph to have 5px (pixels) of padding all around it, you could use:

p { padding: 5px 5px 5px 5px; }

You can also use auto or a % (percentage), just like a margin.

The four individual padding properties are padding-top, padding-right, padding-bottom, and padding-left.

Ready to test your skills? Make a paragraph selector with padding of 10px on the right and left, and 5px on the top and bottom. Add a background-color of #EEEEEE to spice things up.

Click here if you get stuck or want to see how I did it.

advertisement
Our Hosting Partners:

The Original $3.15/mo. FatCow Plan - Unlimited Disk Space, Unlimited Transfer, Unlimited E-mails & Site building tools.

iPage Hosting $4.25/mo
1&1 Hosting $6.99/mo

Free Domain Name If you Order Today!

Copyright © Dave Kristula. All Rights reserved.