margin left div code example

Example 1: how to add a left margin in css

<html>
   <head>
   </head>

   <body>
      <p style = "margin-left: 15px; border:1px solid black;">
         This is a paragraph with a specified left margin
      </p>
      
      <p style = "margin-left: 5%; border:1px solid black;">
         This is another paragraph with a specified top margin in percent
      </p>
   </body>
</html>

Example 2: css margin left

p.ex1 {
 margin-left: 30px;
 }

Example 3: how do I add a vertical margin in css

subject {
  margin-top: /*the size of the margin */ (example: 100px)
  /* or */
  margin-bottom: /*the size of the margin */ (example: 100px)
}

Tags:

Css Example