CSS margin top is used to set the space between the HTML element border and its content from the top.
Syntax
1 |
margin-top: enter value in px, em or percentage |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<style> .div-margin{ border:1px solid yellow; border-radius:20px; } .para-margin-top{ margin-top:50px; } </style> <div class="div-margin"> <p>This is the my first pargraph.</p> <p class="para-margin-top">This is the top margined paragraph.</p> </div> </body> </html> |
Output
This is the my first pargraph.
This is the top margined paragraph.
CSS margin top values list
Sr. No. | value | Description |
---|---|---|
1 | value | Used to specify the value in px, percentage. The value for this for example 15px. |
2 | initial | Used to define as the property initial value. |
3 | inherit | Used to define the computed value of property on the elements parent. |
4 | unset | Used to define the property either acts as inherit or initial, depending on the property if it is inherited or not. |