HTML 5文档概述算法 [英] HTML 5 Document Outlining Algorithm

查看:96
本文介绍了HTML 5文档概述算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个新网站,我最近开始查看文档概述算法。它声明所有部分都应有标题,部分包括部分导航文章正文(有可能还有一些)。

I am building a new site and I have recently started looking at the Document Outlining Algorithm. It states that all sections should have a header, sections include section, nav, article and body (There are probably some more too).

所以,我有几个导航区域,我的问题是;有标题但是只是将其隐藏在浏览器中是明智的吗?

So, I have a couple of navigation areas and my question is; would it be wise to have a heading but just hide it from the browser?

推荐答案

为内容元素划分内容元素longs( H1 - H6 )。但是不需要提供一个。

Every sectioning content element "longs" for a heading element (h1-h6). But you are not required to provide one.

如果您没有为某个部分提供标题元素,则此部分将包含隐含标题 HTML5大纲工具可能会将这些隐含标题显示为无标题部分或空标题。

If you don’t provide a heading element for a section, this section will have an implied heading. HTML5 outline tools might display those implied headings as "Untitled section" or "Empty title".

因此,当您总是尽可能使用切片内容元素时,即使您没有提供单个标题元素,您的文档大纲也会正确(当然不建议这样做;标题非常有用) !)。

So when you always use sectioning content elements where possible, your document outline will be correct even if you don’t provide a single heading element (of course this is not recommended; headings are very useful!).

这两个文档将具有相同的大纲层次结构:

These two documents will have the same outline hierarchy:

<!-- DOCUMENT A -->
<body>
  <article>
  </article>
  <nav>
  </nav>
</body>



<!-- DOCUMENT B -->
<body>
  <h1>site title</h1>
  <article><h1>main content title</h1></article>
  <nav><h1>navigation title</h1></nav>
</body>



Outline for DOCUMENT A       Outline for DOCUMENT B
1. untitled (body)           1. "site title" (body)
  1. untitled (article)        1. "main content title" (article)
  2. untitled (nav)            2. "navigation title" (nav)






所以没有任何标题就可以使用 nav 。但是,如果您认为标题可能对没有CSS支持的消费者有用(例如,屏幕阅读器用户或搜索引擎),您可以提供标题并在视觉上隐藏它。


So it’s fine to use nav without any heading. But if you think a heading might be useful for consumers without CSS support (e.g., screen reader users or search engines), you can provide a heading and hide it visually.

这篇关于HTML 5文档概述算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆