Reputation: 13
I add a forbody class and put it in the body part of the css. Same for the code in the css. But It doesn't work.
in code
<body class="forbody">
</body>
in css
body .forbody {
padding: 0px;
margin: 0 auto;
max-width: 100px;
height:1150px;
}
Upvotes: 1
Views: 203
Reputation: 585
since you use class for forbody you no need to put body infront, used the class name
<body class="forbody"> - html
.forbody {
padding: 0px;
margin: 0 auto;
max-width: 100px;
height:1150px;
}
or in certain cases you can also do like this if do not want external css or used class :
<body style="padding:0px;margin:0;max-width:100px;height:1150px;">
Upvotes: 1
Reputation: 1114
You don’t need the body
part. The CSS should look like this:
.forbody {
padding: 0px;
margin: 0 auto;
max-width: 100px;
height:1150px;
}
Hope this helps!
Upvotes: 1
Reputation: 116438
Remove the space between body
and .forbody
in the CSS. A space designates another element further down the tree. That is, body .forbody
(with a space) will target children of a body element, with the class "forbody". Without the space, body.forbody
will target body elements themselves, when they have the class "forbody".
Alternatively, if the class "forbody" will only be used for the body - or in other words, you do not need to discern between body.forbody
and p.forbody
for example - you can simply omit the "body" part altogether in the selector, leaving .forbody { ... }
Upvotes: 3