×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
CSS Font property use to design font CSS Margin Property | set the margin
CSS Padding Property | set the paading of a DIV - CSS 3.0
3682    Arnab De    11/05/2017

CSS Padding property

The CSS padding property of CSS sets the padding space on all sides of an HTML element. The space between the content of the element and border of the element is known as padding area.by using padding property, we can create a good look and feel in a web page. Now a days almost all the web pages utilize the padding property of CSS. 

Individual Sides Padding

In CSS, we can set the padding of every side(top, right, bottom, and left) of an element by using the following properties:

  • padding-top
  • padding-right
  • padding-bottom
  • padding-left
softetechnologies

The value of the padding is specified by following values

auto : set by browser
length : specified a margin in pt,cm, px etc
% : % of the width of a container
inherit : value inherit from its parent element.

Example

DIV
{
border-style:solid;
padding-top: 40px;
padding-right: 10px;
padding-bottom: 80px;
padding-left: 20px;
}

<!DOCTYPE html>
<html>
<head>
<title>Outline Demo</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div>On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document.</div>
</body>
</html>

softetechnologies

Shorthand Property

The shorten syntax of the code is possible

p {
padding: 10px 20px 30px 40px;
}

this is same as

padding-top:10px;
padding-right:20px;
padding-bottom:30px;
padding-left:40px;

Four form of shortcut process of padding

  • padding:10px 20px 30px 40px [ top right bottom left ]
  • padding:10px 20px 30px [top (right&left) bottom ]
  • padding:10px 20px [(top&bottom) (right&left)]
  • padding:10px[ all margin ]
softetechnologies

Note 1: Padding property value always set a (+Ve) value, (0) is also allowed.
Note 2: If we do not add any units(cm, px, %, etc.) then the value is treated as 0 (zero) by the browser.
Note 3: We can combine percentage values and fixed values in the CSS padding property.
Note 4: If we provide a value as a percentage, it is relative to the width of the containing block.

If we write the following code

.box
{
padding: 20px;
width: 400px;
}

Now if we create a div using the class box then the actual width of the div will be 400 + 20 (left) + 20 (right) = 440px.

CSS Font property use to design font CSS Margin Property | set the margin
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Albert Einstein
Pure mathematics is, in its way, the poetry of logical ideas.
Albert Einstein
2941
71.28
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     51713
25/06/2018     43591
01/01/2018     42733
28/06/2017     40453
02/08/2017     39256
01/08/2017     33503
06/07/2017     33225
15/05/2017     32613
14/07/2017     28820
11/09/2018     28584
softetechnologies