包装字幕的合适方式是什么?

Kit*_*nde 3 html

我有这样的标题和副标题:

程序员

用bikesheds和perl hacks拯救世界.

我代表的是这样的:

<h1>The Programmer</h1>
<p><strong>Saving the world with bikesheds and perl hacks.</strong></p>
Run Code Online (Sandbox Code Playgroud)

不过这可能更合适:

<h1>The Programmer</h1>
<p class="subtitle">Saving the world with bikesheds and perl hacks.</p>
Run Code Online (Sandbox Code Playgroud)

但是因为subtitle在元素上放一个类似乎没有意义,所以这不会更好:

<h1>The Programmer</h1>
<h2>Saving the world with bikesheds and perl hacks.<h2>
Run Code Online (Sandbox Code Playgroud)

哪个更合适?

Ian*_*ley 5

在HTML4中,我可能会选择第二种方法,但如果你不习惯在非标题标签上有一类字幕,那么可以将类名更改为标语:

<h1>The Programmer</h1>
<p class="tagline">Saving the world with bikesheds and perl hacks.</p>
Run Code Online (Sandbox Code Playgroud)

在HTML5中,你可以使用<section>,<header><hgroup>标签和包装的<h1><h2>版本,给你喜欢的东西:

<section>
    <header>
        <hgroup>
            <h1>The Programmer</h1>
            <h2>Saving the world with bikesheds and perl hacks.<h2>
        </hgroup>
    </header>
    ...
</section>
Run Code Online (Sandbox Code Playgroud)

(或者,您可以使用<article>标记而不是<section>标记 - 或任何其他切片标记 - 由于HTML5处理文档大纲的方式发生了变化).