标题(h1-h6)标签的默认字体像素大小是什么?
答案 0 :(得分:31)
我认为如下:
h1 is 2 em
h2 is 1.5 em
h3 is 1.3 em
h4 is 1 em
h5 is 0.8 em
h6 is 0.7 em
em与像素不同。这是查看尺寸的相对方式。据说我认为大多数浏览器默认为16px(或1em)。
答案 1 :(得分:20)
另一种表达方式是:
h1 is 32px (2em)
h2 is 24px (1.5em)
h3 is 20.8px (1.3em)
h4 is 16px (1em)
h5 is 12.8px (0.8em)
h6 is 11.2px (0.7em)
答案 2 :(得分:3)
要获得实际证据,请使用默认的Mozilla Firefox样式查看html.css(171 - 237):
h1 {
font-size: 2em;
}
h2 {
font-size: 1.5em;
}
h3 {
font-size: 1.17em;
}
h4 {
font-size: 1.00em;
}
h5 {
font-size: 0.83em;
}
h6 {
font-size: 0.67em;
}
整个css是:
h1 {
display: block;
font-size: 2em;
font-weight: bold;
margin-block-start: .67em;
margin-block-end: .67em;
}
h2,
:-moz-any(article, aside, nav, section)
h1 {
display: block;
font-size: 1.5em;
font-weight: bold;
margin-block-start: .83em;
margin-block-end: .83em;
}
h3,
:-moz-any(article, aside, nav, section)
:-moz-any(article, aside, nav, section)
h1 {
display: block;
font-size: 1.17em;
font-weight: bold;
margin-block-start: 1em;
margin-block-end: 1em;
}
h4,
:-moz-any(article, aside, nav, section)
:-moz-any(article, aside, nav, section)
:-moz-any(article, aside, nav, section)
h1 {
display: block;
font-size: 1.00em;
font-weight: bold;
margin-block-start: 1.33em;
margin-block-end: 1.33em;
}
h5,
:-moz-any(article, aside, nav, section)
:-moz-any(article, aside, nav, section)
:-moz-any(article, aside, nav, section)
:-moz-any(article, aside, nav, section)
h1 {
display: block;
font-size: 0.83em;
font-weight: bold;
margin-block-start: 1.67em;
margin-block-end: 1.67em;
}
h6,
:-moz-any(article, aside, nav, section)
:-moz-any(article, aside, nav, section)
:-moz-any(article, aside, nav, section)
:-moz-any(article, aside, nav, section)
:-moz-any(article, aside, nav, section)
h1 {
display: block;
font-size: 0.67em;
font-weight: bold;
margin-block-start: 2.33em;
margin-block-end: 2.33em;
}
答案 3 :(得分:1)
h1-h6标签的大小因浏览器而异。没有W3规范来强制标题标签使用标准尺寸。每个浏览器都实现了自己的浏览器。
建议使用CSS规范器使大小在所有浏览器中保持一致。为此,您可以定义代码的自定义尺寸以覆盖默认浏览器值。