This question already has an answer here:
这个问题在这里已有答案:
- Should I set the default font-size on the body or html element? 3 answers
- 我应该在body或html元素上设置默认的font-size吗? 3个答案
I am working in a project and our client wants to follow all the best practices and web standards. I need a little help here. I just want to know
Where shall I define the font-size
in my css(external)
我正在一个项目中工作,我们的客户希望遵循所有最佳实践和Web标准。我需要一点帮助。我只是想知道我在哪里定义我的css中的字体大小(外部)
in html {...}
or in body{....}
which is best and why?
在html {...}或身体{....}这是最好的,为什么?
3 个解决方案
#1
0
You can do it in both. Like:
你可以在两者中做到这一点。喜欢:
Css:
CSS:
html, body { font-size: ...; }
I prefer, to use the
我更喜欢,使用
p{}
h1{}
h2{}
To set the font-sizes on different tags
在不同标签上设置字体大小
#2
0
There is no reason to apply font-size
to html
because there should be no text displayed outside of the body.
没有理由将字体大小应用于html,因为在正文外部不应显示任何文本。
However both should work.
但两者都应该有效。
#3
-1
I learned CSS always setting body font-size at 62.5%.
我学会了CSS总是将body font-size设置为62.5%。
That way you get 1em=10px for other element on the body while changing
这样你在改变时可以获得身体上其他元素的1em = 10px
#1
0
You can do it in both. Like:
你可以在两者中做到这一点。喜欢:
Css:
CSS:
html, body { font-size: ...; }
I prefer, to use the
我更喜欢,使用
p{}
h1{}
h2{}
To set the font-sizes on different tags
在不同标签上设置字体大小
#2
0
There is no reason to apply font-size
to html
because there should be no text displayed outside of the body.
没有理由将字体大小应用于html,因为在正文外部不应显示任何文本。
However both should work.
但两者都应该有效。
#3
-1
I learned CSS always setting body font-size at 62.5%.
我学会了CSS总是将body font-size设置为62.5%。
That way you get 1em=10px for other element on the body while changing
这样你在改变时可以获得身体上其他元素的1em = 10px