将 HTML5 元素映射到 HTML 类和 ID,但是标头标签又如何呢?

发布于 2024-09-14 05:16:46 字数 891 浏览 1 评论 0原文

在工作中,我们开始遵循这个特定指南来慢慢实现 HTML5 的好处:

http:// oli.jp/2008/html5-class-cheatsheet/

使用 HTML5 结构的基本思想,但使用带有类和 ID 的 HTML4 div。我们知道 Javascript 脚本可以生成所需的 HTML5 元素(因此 IE 实际上可以对它们进行样式设置,否则不会!),但我们强调让所有网站都可访问,在 IE6+ 上工作并且不需要 Javascript具有功能性。

我们已经开始使用 HTML5 文档类型,因为拥有“data-”属性的力量对我们很有用。 (ala John Resig 的文章 http://ejohn.org/blog/html-5- data-attributes/

第一篇文章建议的所有内容对我们来说似乎都很好,但一个令人困惑的领域是如何处理标头标签层次结构。对于每个定义的块(无论是文章、旁白、页脚等),我们是否再次从顶部开始标题层次结构?例如,对于一篇文章,h1、h2、h3...。然后页面上的下一篇文章将有 h1、h2、h3... 然后对于页脚(如果有页眉),它将再次开始 h1、h2、h3... 顺便说一句,它将再次开始h1、h2、h3...

...如果是这种情况,那么页面上有大量 h1、h2、h3 对于搜索引擎和屏幕阅读器等内容有何影响?我们正在使用 html5 文档类型,但并没有真正使用新的文章、页脚、导航标签,而是考虑使用 HTML5 的标题层次结构方式。

任何人都可以帮助清除这个问题的泥浆吗?

at work we're starting to follow this particular guide for slowly implementing HTML5 goodies:

http://oli.jp/2008/html5-class-cheatsheet/

The basic idea of using HTML5 structure, but with HTML4 divs with classes and IDs instead. We're aware of Javascript scripts that can genearate the require HTML5 elements (so IE can actually style them, otherwise it won't!) but we make a point of getting all our sites to be accesible, work on IE6+ and not require Javascript to be functional.

We've started to use the HTML5 doctype already, because having the power of the 'data-' atributes is useful to us. (ala John Resig's article http://ejohn.org/blog/html-5-data-attributes/)

All of what the first article suggests seems pretty good to us, but one area of confusion is what to do with header tag hierarchy. For each defined block (be it an article, an aside, a footer etc) do we start of the header hierarchy from the top again? So h1, h2, h3... for an article, for example. Then the next article on the page would have h1, h2, h3... then for the footer (if it has headers) then it'll start again h1, h2, h3... and for an aside it'll start again h1, h2, h3...

...if this is the case, what is the impact of having lots of h1, h2, h3 on a page for such things like search engines and screen readers? We're using the html5 doctype, but not really using the new article, footer, nav tags but are thinking of using the HTML5 way of header hierarchy.

Can anyone help clear the mud with this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟柳画桥 2024-09-21 05:16:46

如果您没有使用实际分区元素,则不应“重置”为h1。也就是说,以下内容是合适的:

<h1>Site title</h1>
<div class=article>
  <h2>The most interesting article ever!</h2>
  <div class=section>
    <h3>Foo</h3>
    <p>Bar
  </div>
  <div class=section>
    <h3>Baz</h3>
    <p>Quux
  </div>
</div>

对于实际元素,您可以使用其中之一

<h1>Site title</h1>
<article>
  <h2>The most interesting article ever!</h2>
  <section>
    <h3>Foo</h3>
    <p>Bar
  </section>
  <section>
    <h3>Baz</h3>
    <p>Quux
  </section>
</article>

,或者

<h1>Site title</h1>
<article>
  <h1>The most interesting article ever!</h1>
  <section>
    <h1>Foo</h1>
    <p>Bar
  </section>
  <section>
    <h1>Baz</h1>
    <p>Quux
  </section>
</article>

我建议使用 HTML5 Outliner 检查您使用的标题是否正确。

If you're not using the actual sectioning elements, you should not "reset" to h1. That is, the following would be appropriate:

<h1>Site title</h1>
<div class=article>
  <h2>The most interesting article ever!</h2>
  <div class=section>
    <h3>Foo</h3>
    <p>Bar
  </div>
  <div class=section>
    <h3>Baz</h3>
    <p>Quux
  </div>
</div>

With the actual elements, you could use either

<h1>Site title</h1>
<article>
  <h2>The most interesting article ever!</h2>
  <section>
    <h3>Foo</h3>
    <p>Bar
  </section>
  <section>
    <h3>Baz</h3>
    <p>Quux
  </section>
</article>

or

<h1>Site title</h1>
<article>
  <h1>The most interesting article ever!</h1>
  <section>
    <h1>Foo</h1>
    <p>Bar
  </section>
  <section>
    <h1>Baz</h1>
    <p>Quux
  </section>
</article>

I suggest using the HTML5 Outliner to check if your use of headings looks right.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文