Saturday, March 10, 2018

Css padding (Css tutorial)

Hello guys! evening and welcome to this section of my tutorial on CSS. In this tutorial i want to talk about CSS Paddings.

The padding property allows you to specify how much space should appear between the content of an element and its border:

The value of this attribute should be either a length, a percentage, or the word inherit. If the value is inherit, it will have the same padding as its parent element. If a percentage is used, the percentage is of the containing box.

The following CSS properties can be used to control lists. You can also set different values for the padding on each side of the box using the following properties:
  • The padding-bottom specifies the bottom padding of an element.
  • The padding-top specifies the top padding of an element.
  • The padding-left specifies the left padding of an element.
  • The padding-right specifies the right padding of an element.
  • The padding serves as a shorthand for the preceding properties.
Now, lets take a look at how to make use of these properties with few examples.

The padding-bottom Property
The padding-bottom property sets the bottom padding of an element. This can take a value in terms of length of %.
 
Below is a short example:

<p  style="padding-bottom: 10px;  border:2px  solid  black;">
This is a paragraph with a specified bottom padding.
</p>

<p  style="padding-bottom: 3%;  border:2px  solid  black;">
This is another paragraph with a specified bottom padding in percent.
</p>

You can also read: Fonts (Css tutorial)

The padding-top Property
The padding-top property sets the top padding of an element. This can take a value in terms of length of %.
 
Below is a short example:

<p  style="padding-top: 10px;  border:2px  solid  black;">
This is a paragraph with a specified top padding.
</p>

<p  style="padding-top: 3%;  border:2px  solid  black;">
This is another paragraph with a specified top padding in percent.
</p>

You can also read: Html Document structure

The padding-left Property
The padding-left property sets the left padding of an element. This can take a value in terms of length of %.
 
Below is a short example:

<p  style="padding-left: 10px;  border:2px  solid  black;">
This is a paragraph with a specified left padding.
</p>

<p  style="padding-left: 3%;  border:2px  solid  black;">
This is another paragraph with a specified left padding in percent.
</p>

You can also read: Html - Text Links

The padding-right Property
The padding-right property sets the right padding of an element. This can take a value in terms of length of %.
 
Below is a short example:

<p  style="padding-right: 10px;  border:2px  solid  black;">
This is a paragraph with a specified right padding.
</p>

<p  style="padding-right: 3%;  border:2px  solid  black;">
This is another paragraph with a specified right padding in percent.
</p>

The Padding Property
The padding property sets the left, right, top, bottom padding of an element. This can take a value in terms of length of %.

Below is a short example:

<p  style="padding: 10px;  border:2px  solid  black;">
all four padding will be 10px.
</p>

<p  style="padding:10px  3%;  border:2px  solid  black;">
top and bottom padding will be 10px, while the left and right padding will be 3% of the total width of the document.
</p>

<p  style="padding:10px  3%  10px;  border:2px  solid  black;">
top padding will be 10px, while the left and right padding will be 3% of the total width of the document, and lastly the bottom padding will be 10px.
</p>

<p  style="padding:10px  3%  10px  10px;  border:2px  solid black;">
top padding will be 10px, right padding will be 3% of the total width of the document, and lastly the bottom padding and top padding will be 10px.
</p>

Alright thats it for this tutorial on CSS paddings, always feel free to ask your questions in areas you don't understand very well, your questions will be attended to as soon as possible.
Like our facebook page and also subscribe with us to get our tutorial posts delivered directly to your emails.
You can follow us on twitter 
You can follow us on google+
You can also follow us on pinterest 

Links to previous tutorials on CSS : Css Introduction (Css tutorial) ,  Syntax (Css tutorial)  ,  Inclusion (Css tutorial) , Css Measurement Units (Css tutorial)  , Backgrounds (Css tutorial) , Fonts (Css  tutorial)  , Text (Css tutorial)  , Images (Css tutorial)  , Links (Css tutorial) , Css table (Css tutorial) , Css border (Css tutorial)  , Css margin (Css tutorial)  , Css List (Css tutorial)
Share:

0 comments:

Post a Comment