我还没有找到这个问题,如果它已经在这里,请随时关闭。
您最喜欢在 HTML 中设置标题的方式是什么?
<h1> Main Part </h1>
<h2> In here there are many sections</h2>
<div id="section1">
<h1> Section 1 </h1>
<h2> Subtitle </h2>
</div>
<div id="section2">
<h1> Section 2 </h1>
<h2> Subtitle </h2>
</div>
或者
<h1> Main Part </h1>
<h2> In here there are many sections</h2>
<div id="section1">
<h3> Section 1 </h3>
<h4> Subtitle </h4>
</div>
<div id="section2">
<h3> Section 2 </h3>
<h4> Subtitle </h4>
</div>
...意思是从顶部开始排序,或者从页面的每个部分中的 H1 开始,即不同的部分(/container/sidebar/whatever)。
还有其他的做法。那么你更喜欢哪一个呢?你有没有不同的做法,如果是这样,怎么做?那里有最佳实践吗?这会影响SEO吗?哪一个是最语义化的?
编辑:这里的人们似乎同意第二种解决方案。这也是我的观点,但这是导致我提出这个问题的问题:如果我想在主要部分放置一个 h3 怎么办?
<h1> Main Part </h1>
<h2> In here there are many sections</h2>
<h3> Something else </h3>
<div id="section1">
<h3> Section 1 </h3>
<h4> Subtitle </h4>
</div>
<div id="section2">
<h3> Section 2 </h3>
<h4> Subtitle </h4>
</div>
我必须重写所有部分吗?这可能是一个完整的网站!通常很难确切地知道您将在一个部分中有多少个字幕。
请记住,这些部分可能是侧边栏或看起来完全不同的东西以及页面上的其他位置。