본문 바로가기
HTML CSS

KokoaTalk Clone Coding: CSS margin

by jane.dev 2021. 5. 2.
반응형

block have three visuals: margin, padding, border

margin is the spaces from the border of the box to the outside.

 

<html>

    <head>

    <style>

         html {

             background-color: gray;

         }

         div {

             height: 200px;

             width: 200px;

             background-color: thistle;

         }

     </style>

     </head>

     <body>

          <div></div>

     </body>

</html>

the browser make space
margin: 8px(default)

 

<html>

    <head>

    <style>

         html {

             background-color: gray;

         }

         body {

            background-color: steelblue;

         div {

             height: 200px;

             width: 200px;

             background-color: thistle;

         }

     </style>

     </head>

     <body>

          <div></div>

     </body>

</html>

body have background color

<html>

    <head>

    <style>

         html {

             background-color: gray;

         }

         body {

            background-color: steelblue;

            margin: 0;

         div {

             height: 200px;

             width: 200px;

             background-color: thistle;

         }

     </style>

     </head>

     <body>

          <div></div>

     </body>

</html>

margin: 0