Home > Enterprise >  Is there any method to solve this CSS margin issue?
Is there any method to solve this CSS margin issue?

Time:01-08

The margin tag inside the doesn't work! as you can see above the "user agent stylesheet", it shows that margin doesn't work. I've tried finding missing characters, but i think there are none of them.

<!DOCTYPE html>
<html lang="kr"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <link href="./Home-wonhui&#39;s first website._files/styles.css" rel="stylesheet">
     <title>
        Home-wonhui's first website.
    </title>
     <meta name="description" content="this is my website" />
     
     <style> 
        div {
            height: 150px;
            width: 150px;
            background-color: aquamarine;
        }
        body {
            margin: 10;
            background-color: wheat;
        }
     </style>
    </head>
    <body>
        <div>HELLO!!!!</div>
        <code>H i</code>
    </body>
</html>

stylesheet is a empty file, which means nothing in there.enter image description here

CodePudding user response:

There is no unit defined for your margin. 10 is not a valid value.

https://www.w3schools.com/cssref/pr_margin.asp

CodePudding user response:

You are almost there!!!!

You didn't specify any type of units to the margin that's why margin property is not applied.

Updated code:

<!DOCTYPE html>
<html lang="kr"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <link href="./Home-wonhui&#39;s first website._files/styles.css" rel="stylesheet">
     <title>
        Home-wonhui's first website.
    </title>
     <meta name="description" content="this is my website" />
     
     <style> 
        div {
            height: 150px;
            width: 150px;
            background-color: aquamarine;
        }
        body {
            margin: 10px;
            background-color: wheat;
        }
     </style>
    </head>
    <body>
        <div>HELLO!!!!</div>
        <code>H i</code>
    </body>
</html>

  •  Tags:  
  • Related