简体   繁体   English

为什么<h5>和<h6>字体大小小于<p>在大多数用户代理默认样式表中?

[英]Why do <h5> and <h6> have smaller font sizes than <p> in most user agent default stylesheets?

The default <h5> and <h6> section headings in HTML5 have font sizes of 0.83em and 0.67em , respectively, while the default <p> font size is 1em . HTML5 中默认的<h5><h6>部分标题的字体大小分别为0.83em0.67em ,而默认的<p>字体大小为1em That means in a block of text containing <h5> , <h6> and <p> tags, these headings will be smaller than the text they head:这意味着在包含<h5><h6><p>标签的文本块中,这些标题将小于它们所指向的文本:

与段落字体大小相关的从 h1 到 h6 的默认字体大小

(Default body font size above is 14px ) (上面的默认正文字体大小为14px

This seems counter-intuitive: headings are supposed to draw the eye and command the start of a section, and font size is an important visual cue.这似乎违反直觉:标题应该吸引眼球并指示部分的开头,而字体大小是重要的视觉提示。 Is there a reason why the default font sizes make these headings smaller than the text under them?默认字体大小使这些标题比它们下面的文本小有什么原因吗?

I've been searching through W3C mailing lists but haven't found any debate on this decision. 我一直在搜索W3C邮件列表,但没有对此决定进行任何辩论。

Here's what I can infer: 这是我可以推断的:

1995 1995年

The first published version of the HTML spec (before CSS came into play) actually specified that h4 and h5 should be "normal font" size. HTML规范的第一个发布版本(在CSS出现之前)实际上指定 h4h5应该为“常规字体”大小。 The font size for h6 wasn't explicitly specified, but I would presume that it was also the normal font size. 没有明确指定h6的字体大小,但我想它也是正常的字体大小。

 H3 Italic, large font, slightly indented from the left margin. One or two blank lines above and below. H4 Bold, normal font, indented more than H3. One blank line above and below. H5 Italic, normal font, indented as H4. One blank line above. H6 Bold, indented same as normal text, more than H5. One blank line above. 

1996 1996年

CSS broke onto the scene. CSS出现了。 Or really, limped onto the scene and broke . 或者说真的,到现场摔断了 The first recommended default style sheet for browsers specified only: 仅为指定的浏览器推荐的第一个默认样式表:

 H1 { font-size: xx-large } H2 { font-size: x-large } H3 { font-size: large } 

h4 through h6 would thus be 1em . h4h6将因此为1em

1997 1997年

HTML 3.2 dropped any font-size recommendations relative to document text, only recommending : HTML 3.2删除了与文档文本相关的所有字体大小建议,仅建议

More important headings are generally rendered in a larger font than less important ones. 通常,较不重要的标题将以较大的字体显示。

This conflicts a bit with CSS1, but the two were not integral to each other at the time. 这与CSS1有点冲突,但是两者在当时并不是彼此不可分割的。 Most styling was still done with inline HTML attributes, which were still very much not deprecated. 大多数样式仍然是使用内联HTML属性完成的,但仍然不建议过时。

1998 1998年

CSS2 came out, and it removed a default style sheet from its own spec, and instead linked to the new sample style sheet for HTML 4.0 in HTML's specification. CSS2发布了,它从自己的规范中删除了默认样式表,而是链接到 HTML规范中的HTML 4.0的新示例样式表

This is the origin of headers explicitly being set smaller than 1em , at least as far as I can tell. 至少据我所知, 这是显式设置为小于1em的标头的来源 The recommended HTML 4.0 stylesheet specifies the values most browsers keep to today as defaults: 推荐的HTML 4.0样式表指定了大多数浏览器今天保留的默认值:

 H5 { font-size: .83em; line-height: 1.17em; margin: 1.67em 0 } H6 { font-size: .67em; margin: 2.33em 0 } 

Ooh, digital archaeology! 哦,数字考古!

So, it turns out that you can trace this back to the default "styles" (not exactly CSS!) of Internet Explorer 3-4 and Netscape Navigator 3-4. 因此,事实证明您可以将其追溯到Internet Explorer 3-4和Netscape Navigator 3-4的默认“样式”(不完全是CSS!)。 More specifically, they are likely pulled from IE4pp2 but introduced with IE3. 更具体地说,它们很可能是从IE4pp2中提取的,但随IE3一起引入。 How IE/Microsoft decided on those values is, unfortunately, lost to the sands of time (at least publicly - it may well be available in Microsoft internal email archives ... anyone know a MS employee?). 不幸的是,IE / Microsoft如何决定这些价值观已失去了时间(至少是公开的-它很可能可以在Microsoft内部电子邮件存档中找到……任何认识MS员工的人?)。

I've tried to reconstruct the chain below. 我试图重建下面的链。


As Jacob mentioned, the earliest draft of CSS2 from November 1997 includes a sample stylesheet that defines h5 as .83em and h6 as .67em . 正如Jacob提到的,1997年11月以来CSS2的最早草案包括一个示例样式表 ,该样式表h5定义为.83em ,将h6定义为.67em It also notes: 它还指出:

The Base Stylesheet describes the typical rendering of all HTML 4.0 [HTML40]) elements visual UAs. 基本样式表描述了所有HTML 4.0 [HTML40])元素可视化UA的典型呈现。 The style sheet is based on extensive research on how current UAs render HTML, and developers are encouraged to use it as a default style sheet in their implementations. 样式表基于对当前UA如何渲染HTML的广泛研究,因此鼓励开发人员在其实现中将其用作默认样式表。


Digging a bit further, we can find a "base stylesheet" with the same values, which notes: 进一步研究,我们可以找到一个具有相同值的“基本样式表” ,其中指出:

I developed the sample stylesheet for the W3C CSS2 Draft, but the editorial development of materials at this location has no official W3C status. 我为W3C CSS2草案开发了样式表样例,但是此位置的材料编辑开发并没有W3C正式地位。

... ...

The Base Stylesheet describes the "consensus default" rendering of all HTML 4.0 elements in Mosaic-derivative Web browsers (Netscape Navigator and Microsoft Internet Explorer). 基本样式表描述了马赛克衍生的Web浏览器(Netscape Navigator和Microsoft Internet Explorer)中所有HTML 4.0元素的“共识默认”呈现。 It is intended as a basis for editing or "cascading in" other stylesheet modules, an informative reference, an (unofficial) complement to the HTML 4.0 specification, an exercise in stylesheet architecture, and a browser testing tool. 它旨在作为编辑或“级联”其他样式表模块的基础,信息性参考,对HTML 4.0规范的(非正式)补充,样式表体系结构的练习以及浏览器测试工具。 The Base Stylesheet captures the status quo in order to move beyond it. 基本样式表捕获了现状,以便超越现状。

We can further track this base stylesheet back to the www-style mailing list. 我们可以进一步将此基本样式表追溯到www样式的邮件列表。


Of possible interest is that around that time, W3C endorsed a set of "Core Style Sheets" intended(?) to become a better default. 可能感兴趣的是,在那时, W3C批准了一组旨在(?)成为更好默认值的“核心样式表” These stylesheets ( now accessible via the Internet Archive ) do use larger values for all headings , resulting in h6 at 1em and h5 at 1.17em . 这些样式表( 现在可以通过Internet存档访问 )确实对所有标题使用较大的值 ,从而导致h61emh51.17em Unfortunately, it seems this set of stylesheets never really took off, so we're left with the weirdly small h5 and h6 . 不幸的是,这组样式表似乎从未真正普及过,因此我们只剩下了奇怪的小h5h6

No, it is just a default font size. 不,这只是默认字体大小。 Usually, you edit the heading with a CSS file where you are able to choose every font size. 通常,您使用CSS文件编辑标题,您可以在其中选择每种字体大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM