What is the default margin that HTML sets for its tags? I noticed there is some auto margin, but I was wondering if anyone knows what it is (and if it's in px or % etc.).
In most major browsers, the default margins on all sides are 8px. It is defined in pixels by the user-agent-stylesheet provided by the browser.
Some browsers allow you to create and use your own user-agent-stylesheet, but if you are developing a website I recommend not changing this as your users most likely won't Make a modified stylesheet and you'll see a different page than you did.
If you want to change it, you can do this:
body {
margin: 0px;
padding: 0px;
...
}
But if you have a large project and want to be more complete, use normalize.css. It resets many default values to be consistent across browsers.
According to W3School’s CSS reference, The default attributes and values of the body tag are,
By accessing the Calculation Pane in Chrome Dev Tools.
In most major browsers, the default margins on all sides are
8px
. It is defined in pixels by theuser-agent-stylesheet
provided by the browser.Some browsers allow you to create and use your own
user-agent-stylesheet
, but if you are developing a website I recommend not changing this as your users most likely won't Make a modified stylesheet and you'll see a different page than you did.If you want to change it, you can do this:
But if you have a large project and want to be more complete, use normalize.css. It resets many default values to be consistent across browsers.