![]() |
VOOZH | about |
The margin-top property in CSS is used to add space above an element. It helps control the layout and spacing between elements on a webpage.
Syntax:
margin-top: length | auto | initial | inherit;Property values:
Example: Here, we use margin-top: length; property.
Example: Here, we are using margin-top: %; property.
Example: Here, we are using margin-top: auto; property.
Example: Here, we are using margin-top: initial; property.
Example: Here, we are using margin-top: inherit; property.
Note: Top and bottom margins of elements are sometimes collapsed into a single margin that is equal to the largest of the two margins. This does not happen on horizontal (left and right) margins but only in the case of vertical (top and bottom) margins. It is called Margin Collapse.