默认的“< body>"边距有多宽? [英] How wide is the default `<body>` margin?
问题描述
HTML为其<body>
标签设置的默认margin
是什么?我注意到有一些自动边距,但是我想知道是否有人知道它有多少(以及它是否在px
或%
中,等等).
What’s the default margin
that HTML sets for its <body>
tag? I noticed that there’s some automatic margin, but I’m wondering if anyone knows how much it is (and whether it’s in px
or %
, etc.).
推荐答案
在大多数主流浏览器中,默认值在所有方面均为8px
.它由浏览器提供的user-agent-stylesheet
以像素为单位定义.
In most major browsers, the default margin is 8px
on all sides. It is defined in pixels by the user-agent-stylesheet
your browser provides.
某些浏览器允许您创建和使用自己的user-agent-stylesheet
,但是如果您正在开发网站,则建议不要更改此内容,因为您的用户很可能不会修改样式表,然后会看到一个与您的页面不同.
Some browsers allow you to create and use your own user-agent-stylesheet
, but if you are developing a website, I would recommend staying away from changing this, since your users most likely will not have a modified stylesheet and would then see a different page than you do.
如果要更改它,只需执行以下操作:
If you want to change it, you can just do this:
body {
margin: 0px;
padding: 0px;
...
}
但是,如果您有一个大型项目,并且想要更完整,请使用 normalize.css .它将重置许多默认值,以使各浏览器保持一致.
But if you have a large project and want to be more complete, use normalize.css. It resets a lot of default values to be consistent across browsers.
这篇关于默认的“< body>"边距有多宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!