1. Home
  2. Computing & Technology
  3. Web Design / HTML

Using Shorthand Notation with CSS margin, padding, and border Styles

By , About.com Guide

When using the shorthand versions of certain CSS properites like margin, padding, and border, you put the rule in the order
top right bottom left

But if you leave off certain numbers you can have more control:

margin: 0px;
defines all margins as 0px.

padding: 10px 5px;
defines the top and bottom padding as 10px each and the right and left padding as 5px each.

border-width: 1px 5px 2px;
defines the top border as 1px, the right and left border as 5px and the bottom border as 2px.

margin: 1px 10px 5px 3px;
the standard usage, defining the top as 1px, the right as 10px, the bottom as 5px, and the left as 3px.

Explore Web Design / HTML
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML

©2009 About.com, a part of The New York Times Company.

All rights reserved.