Home Advertise with us Forum Articles Sitemap Contact
Logo  

CSS Padding

The CSS padding attribute is often considered to be synonymous to CSS margin. The only noticeable difference between the two is that, margin specifies the white space around the border of the HTML element, while padding defines the space within the border. Apart from this minor difference, defining the values for padding is the same as defining it for margin. The two types of values that can be used for defining the padding are:

  • Length – this is used to define a fixed padding either in pixels, em, pt or others.

  • % - the padding is defined in percentage of the containing element.

Similar to the borders & margins, for padding also it is possible to define different styles for different sides.

Example:

padding-top:15px;

padding-bottom:15px;

padding-right:20px;

padding-left:20px;


There are several properties to be considered at the time of defining padding & thus, CSS offers a convenient way of specifying all padding properties within one single property.

Example: padding:15px 20px;