【发布时间】:2016-09-17 13:32:24
【问题描述】:
问题:
为什么将<h1> 和<h2> 标签放在<article> 中时具有相同的font-size?
输出:
然后我想也许只是我的眼睛欺骗了我所以我测量了它。
我原来是一样大的。
我查看了以下链接 (http://w3c.github.io/html/rendering.html#sections-and-headings) 我了解到它是基于层次结构的,但 <h1> 和 <h2> 处于同一层次结构。
因此,<h1> 应该是 2em,<h2> 应该是 1.5em。
代码:
<!DOCTYPE html>
<html>
<head>
<title>Headings</title>
<meta charset="utf-8">
</head>
<body>
<article>
<h1>This is h1.</h1>
<h2>This is h2.</h2>
<h3>This is h3.</h3>
<h4>This is h4.</h4>
<h5>This is h5.</h5>
<h6>This is h6.</h6>
</article>
</body>
</html>
【问题讨论】:
-
您可以在浏览器的控制台中查看“计算样式”,而不是测量字母。
-
@Lends 很好的建议,谢谢。
-
specs you linked 表示
x h1的字体大小应为 1.5 em,x hgroup > h1 ~ h2的字体大小应为 1.17 em(其中x是<article>,@ 987654340@、<nav>和<section>。我认为浏览器只实现了 h1-in-article 部分而不是 h2-in-article 部分(+其余部分),这就是它们的大小相同的原因在<article>
标签: css html html-heading