CSS Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
CSS Topics
css tutorials Introduction
Types Types
Background Properties Background Properties
Text Properties Text Properties
Font Properties Font Properties
Box Properties BOX Properties
Border Properties Border Properties
Margin Properties Margin Properties
Padding Properties Padding Properties
Special Topics Special Topics
Forums Ask Your Doubts
Scraps More about CSS
Feedback Feedback
 




Padding Properties - CSS


Tutorials »Css »

Topic

Handling Padding properties in Html.



Explanation

Property: Padding

All the padding (top, right, bottom, left) can be combined using this single tag. Usage:
padding: 20px;
padding: 10px 20px 30px 10px;
padding: 10px 20px;
padding: 20px 10px 30px;

Definition:
The padding can be set using the tag "padding".
It takes the following values.

a) 20px : This will set a padding of 20px on the four sides (top, right, bottom, left).
b) 10px 20px 30px 10px: This format will set the padding in the order of top,right,bottom,left.
c) 10px 20px : This format will set the padding for top and right. Bottom will take the top padding value (10px) and left will take right paddings value(20px).
d) 20px 10px 30px: This format will set the padding for top and right and bottom. left will take the right paddings value.

The values can be in percentage or points or pixels.

Example 1:
<div align=right style="padding: 20px;">
Here we have set a padding of 20 pixels.
You can see that this paragraph has paddings on all the four sides.
</div>

Result:
Here we have set a padding of 20 pixels. You can see that this paragraph has paddings on all the four sides.


Example 2:
<div style="padding: 10px 50px 30px 5px;">
Here we have set a padding with four values.
You can see that this paragraph has padding of 10px on top, 50px on right, 30px on bottom and 5px on left.
</div>

Result:
Here we have set a padding with four values. You can see that this paragraph has padding of 10px on top, 50px on right, 30px on bottom and 5px on left.


Example 3:
<div style="padding: 20px 40px;">
Here we have set a padding with two values.
You can see that this paragraph has paddings on 20px on top and bottom and 40px on left and right.
</div>

Result:
Here we have set a padding with two values. You can see that this paragraph has paddings on 20px on top and bottom and 40px on left and right.


Example 4:
<div style="padding: 10px 50px 40px;">
Here we have set a padding with three values.
You can see that this paragraph has paddings of 10px on top, 50px on right , 40px on bottom. left padding took values from its right counter part as 50px.
</div>

Result:
Here we have set a padding with three values. You can see that this paragraph has paddings of 10px on top, 50px on right , 40px on bottom. left padding took values from its right counter part as 50px.




A Note
CSS - Cascading Style Sheets can be used along with html tags as explained in this site. This simple CSS will help you to create much elegant and neat html web pages. This does not need any additional softwares or codings. All web browser are capable of handing CSS codes.

Note 2: If required you can using <span> instead of <div> tags. div tag will start and end on new lines. span will not exceed the tag area.
Other Links

web hosting