Usage of margin-top property with CSS

The margin-top specifies the top margin of an element. It can have a value in length, % or auto.

Example

You can try to run the following code to set the top margin

<html>
   <head>
   </head>
   <body>
      <p style = "margin-top: 10px; border:2px solid red;">
         This is a paragraph with a specified top margin
      </p>
      <p style = "margin-top: 10%; border:2px solid green;">
         This is another paragraph with a specified top margin in percent
      </p>
   </body>
</html>
Updated on: 2020-01-31T10:24:12+05:30

74 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements