CSS Margin

44 views

 The left margin of an element.

The left margin of an element is set using the margin-left property.

<html>
<head>
<title>Setting the left margin of an element</title>
</head>
<body>
<p>
this is text..
</p>
<p style=”margin-left: 3cm;”>
This is left margin text .
</p>
</body>
</html>

Output.

                                
     This is text.      
                                                     This is left margin text 
 

This is  example, there are two paragraphs. The first paragraph has no specified margin. The second paragraph has a left margin of 3 centimeters.

The right margine of an element.

The right margin of an element is set using the margin-right property.

<html>
<head>
<title>Setting the right margin of an element</title>
</head>
<body>
<p>
this is text..
</p>
<p style=”margin-right: 5cm;”>
This is right margin text .
</p>
</body>
</html>

Output.

                          
                                                     This is right text    
 This is right margin text.

 This is  example, there are two paragraphs. The first paragraph has no specified margin. The second paragraph has a right margin of 5 centimeters.

The top margine of an element.

The top margin of an element is set using the margin-top property.

<html>
<head>
<title>Setting the top margin of an element</title>
</head>
<body>
<p>
this is first top text..
</p>
<p style=”margin-top: 5cm;”>
This is top margin text .
</p>
</body>
</html>

Output.

                                   This is first top text.. 

                                               
                                This is top margin text..

 This is  example, there are two paragraphs. The first paragraph has no specified margin. The second paragraph has a top margin of 5 centimeters.

The bottom margine of an element.

The bottom margin of an element is set using the margin-bottom property.

<html>
<head>
<title>Setting the bottom margin of an element</title>
</head>
<body>
<p>
this is first bottom text..
</p>
<p style=”margin-bottom: 5cm;”>
This is bottom margin text .
</p>
</body>
</html>

Output.

  this is first bottom text..
  This is first bottom text..

This is  example, there are two paragraphs. The first paragraph has no specified margin. The second paragraph has a bottom margin of 5 centimeters.



« Functions void Function »
Posted on Saturday, June 14th, 2008 at 1:11 pm under CSS For Beginners | RSS 2.0 Feed

Post Comment

You must be logged in to post a comment.



ComputerEducationWorld.com All Rights Reserved © RSS | CBSE | Education Boards Of India | What is My IP?