html vs body tag for setting margin 0 |
html vs body tag for setting margin 0 |
mp3909 |
May 5 2020, 12:00 PM
Post
#1
|
Novice Group: Members Posts: 20 Joined: 4-April 20 Member No.: 27,264 |
So I want to have zero margins on my body so I thought if i do the following it would work, but it didn't.
CODE html { margin: 0; } But then i did this and it worked. CODE body { margin: 0; } I'm confused why it did not work when I used the html selector to set margins to zero. |
Christian J |
May 5 2020, 02:12 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
Most browsers use a default margin for BODY, but not for the HTML element.
Here's a list of all(?) HTML elements, though I'm not sure how correct it is. Also browsers may use (or have used) different default styling: https://www.w3schools.com/cssref/css_default_values.asp There also an official but less readable list for HTML4 elements here: https://www.w3.org/TR/CSS2/sample.html (haven't found an official one for HTML5 yet). |
pandy |
May 5 2020, 03:32 PM
Post
#3
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
There also an official but less readable list for HTML4 elements here: https://www.w3.org/TR/CSS2/sample.html (haven't found an official one for HTML5 yet). And not complete unless older browsers are ignored. Some browsers used to use padding on body, and maybe their offspring still do if in Quirks Mode, I don't know. I don't think any browser has applied styling to HTML though. |
mp3909 |
May 9 2020, 06:42 AM
Post
#4
|
Novice Group: Members Posts: 20 Joined: 4-April 20 Member No.: 27,264 |
ok, thanks guys.
|
Lo-Fi Version | Time is now: 25th April 2024 - 01:13 AM |