Tags : HTML/CSS



Box Model

The box model helps us understand the spacing for each element in our web page.

Please read this about the box model

index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Box Model</title>
    <link rel="stylesheet" type="text/css" href="css/styles.css"
  </head>
  <body>
    <p class="demo">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  </body>
</html>
styles.css
.demo {
  border: 10px solid black;
  padding: 5px;
  margin: 50px;
}

Try the following:

  • Add border, padding and margin to the body element.
  • Add border, padding and margin to all the list items to give them proper spacing. Play around with values until you have a good understanding of the box model.