HTML默认身体边距 [英] HTML default body margin
问题描述
HTML为< body>
标签设置的默认边距是多少?我注意到有一些自动保证金,但我想知道是否有人知道它有多少(以及它是以像素还是%等)。
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 pixels 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-styleheet
,但是如果你正在开发一个网站,我建议不要改变它,因为你的用户很可能没有修改样式表,然后会看到与你不同的页面。
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.
这篇关于HTML默认身体边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!