CSS Margin
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 |
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. |
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.. |
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.. |