副标题在语义上最正确的方法是什么? [英] What's the most semantically correct way to do subheadings?
问题描述
做副标题或字幕的最语义上正确的方法是什么?下面的示例.
What's the most semantically correct way to do subheadings or subtitles? Example below.
我们卖苹果,是的!
Lorem ipsum ...
Lorem ipsum...
由于与实际的信息标题相比,副标题的内容并不重要,因此我认为屏幕阅读器和搜索引擎不应将其视为单独的标题.
Since the contents of the subheading aren't of much importance when compared to actual, informative headings, I thought that they should not be seen as separate headings by screen readers and search engines.
所以,我想到的选项如下:
So, the options that I thought of are as follows:
-
< h2>关于</h2>< h3>我们卖苹果,是的!</h3>
->这就是我要避免的事情. -
< h2>关于</h2>< span class ="subheading">我们出售苹果,是的!</span>
->作品.这是最好的方法吗?不知道. -
< h2>关于< span class ="subheading">我们出售苹果,好吧!</span></h2>
->部分标题.我真的不知道这是好事还是坏事.
<h2>About</h2><h3>We sell apples, yay!</h3>
-> This is what I would like to avoid.<h2>About</h2><span class="subheading">We sell apples, yay!</span>
-> Works. Is it the best way? Don't know.<h2>About<span class="subheading">We sell apples, yay!</span></h2>
-> Part of the heading. I don't really know if it's a good or bad thing.
对此有何建议?
推荐答案
HTML5通过 hgroup
标签解决了这一问题.使用它.
HTML5 solves this by way of the hgroup
tag. Use that.
如果您感觉还没有准备好迁移,那么我想您在标记标题时仍应使用适当的标题标签.如果您不满意将两个标题标记为同级,则可以调整副本以将标题的数量减少到一个.
If you feel you're not yet ready to migrate, then I'd say you should still go with proper heading tags whenever you're marking up a heading. If you feel uncomfortable marking up two headings as siblings, perhaps you can adjust your copy to reduce the number of headings to just one.
修改:
Since the time of writing, the future of hgroup
has been endangered: http://dev.w3.org/html5/status/issue-status.html#ISSUE-164
编辑2 :
自2013年4月2日起, hgroup
已从规范中删除: http://lists.w3.org/Archives/Public/public-html-admin/2013Apr/0003.html
As of April 2nd 2013 hgroup
is removed from the spec:
http://lists.w3.org/Archives/Public/public-html-admin/2013Apr/0003.html
(来源: https://twitter.com/iandevlin/status/318961224836587521 )
这篇关于副标题在语义上最正确的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!