html5:分段元素中的标题 - 文档大纲和 SEO 影响

发布于 2024-10-29 14:02:30 字数 1833 浏览 2 评论 0原文

html5 规范

分段内容元素或分段根元素的大纲由一个或多个可能嵌套的部分的列表组成。一个section是一个容器,对应于原始DOM树中的一些节点。每个部分可以有一个与其关联的标题,并且可以包含任意数量的进一步嵌套的部分。大纲算法还将 DOM 树中的每个节点与特定部分和可能的标题相关联。

同样的推理似乎也适用于 html5 文档大纲算法

我一直在使用 HTML5 大纲 (h5o) [link] 工具检查我网站的大纲,但是我很难获得一个清晰的大纲,并且不会被无用的标题所负担过重,因为

坦率地说,这对于导航或页脚之类的东西来说似乎有点过分了。

一种解决方案是用 div 替换这些元素,但这似乎违背了使用 html5 的全部目的。

另一种方法是为所有分段元素设置标题,然后使用CSS 隐藏其中一些标题(同样,基本上是

<nav id="content-nav">
    <h2 class="hidden">Post navigation</h2>
    <ul>
        <li class="alignleft"><?php next_post_link('&#8592; <strong>Next Post</strong><br />%link') ?></li>
        <li class="alignright"><?php previous_post_link('<strong>Previous Post</strong> &#8594;<br />%link') ?></li>
    </ul>
</nav>

这会生成一个显示效果很好的网站,但我在其网站管理员工具帮助项目中看到的问题是 Google 排名。 ://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=66353" rel="noreferrer">链接]关于“隐藏文本和链接”,Google 明确指出 那:

隐藏内容中的文本或链接可能会导致您的网站被视为不可信,因为它向搜索引擎提供的信息与向访问者提供的信息不同。文本(例如过多的关键字)可以通过多种方式隐藏,包括:[...]使用 CSS 隐藏文本...

有些人可能会觉得 Google 是否喜欢他们使用隐藏文本这一事实并不重要,但我的大多数访问者都来了来自谷歌搜索,我不想因为选择使用此设置而受到惩罚。

任何人都可以提供有关该主题的建议吗?

The html5 spec says that:

The outline for a sectioning content element or a sectioning root element consists of a list of one or more potentially nested sections. A section is a container that corresponds to some nodes in the original DOM tree. Each section can have one heading associated with it, and can contain any number of further nested sections. The algorithm for the outline also associates each node in the DOM tree with a particular section and potentially a heading.

and the same reasoning seems applied to the html5 document outline algorithm.

I've been checking my site's outline using the HTML5 outliner (h5o) [link] tool but am having difficulty achieving a clear outline that isn't overburdened with useless titles, because of the fact that elements such as <nav> or <footer> will appear in your outline but will do so as 'untitled' unless you give them an explicit h1-h6 heading.

This seems frankly overkill for things like navigation or footers.

One solution is to replace these elements with divs, but that seems to defeat the whole purpose of using html5.

Another, which I've tentatively tried on my site [link], is to set headings for all sectioning elements and then use CSS to hide the headings for some of them (again, basically <nav> and <footer>, as well as some <section> elements. Here's an example:

<nav id="content-nav">
    <h2 class="hidden">Post navigation</h2>
    <ul>
        <li class="alignleft"><?php next_post_link('← <strong>Next Post</strong><br />%link') ?></li>
        <li class="alignright"><?php previous_post_link('<strong>Previous Post</strong> →<br />%link') ?></li>
    </ul>
</nav>

This results in a nicely-diplaying site, but the issue I see with it is Google ranking. In its Webmasters Tool help item [link] on 'hidden text and links', Google clearly states that:

Hiding text or links in your content can cause your site to be perceived as untrustworthy since it presents information to search engines differently than to visitors. Text (such as excessive keywords) can be hidden in several ways, including: […] Using CSS to hide text…

Some people might feel that whether Google likes the fact they use hidden text or not is immaterial, but most of my visitors come from Google searches and I'd rather not be penalized as a result of choosing to go with this setup.

Can anyone offer advice on the subject?

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

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

发布评论

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

评论(2

十级心震 2024-11-05 14:02:30

我在网站上尝试过的另一种方法是为所有分区元素设置标题,然后使用 CSS 隐藏某些主题的标题(同样,基本上是

这正是我要做的,实际上还没有构建一个 HTML5 网站,但是有趣的是我不久前研究过这个

“标题”或部分标题 。 ,非常适合创建结构或文档大纲(如大纲中所示),它们对于辅助技术用户也非常有用,他们基本上可以通过“选项卡”浏览标题来找到网站的路径,而无需进行操作。 “聆听”所有内容并尝试找出您可能将搜索框放在哪里,

这就是为什么我认为标题/标题应该在那里,即使它们是隐藏的。视觉用户视图(并填充SE;))

并非所有CSS隐藏方法都是相同的

,所以我知道我们不能注销SE,所以您选择隐藏标题的方式很重要,因为您希望它们可用AT(辅助技术)用户.. display: none; 不可靠(某些屏幕阅读器不读取它们),您也无法“tab”找到它们 - 可见性:hidden; 不会删除空格,你仍然无法“tab”找到

那么哪种隐藏方法呢?

.. 恰好有一个非常酷的功能,由 Drupal 社区的成员发现。. 使用 clip: rect(); 属性让每个人都高兴

.my-hidden-element {
  position: absolute;
  clip: rect(1px 1px 1px 1px); /* IE6 & 7 */
  clip: rect(1px, 1px, 1px, 1px);
}

至于 Google,不仅会很难让他们根据 clip 属性“全面禁止/惩罚”,即使确实开始提出旗帜,我认为如果您可以证明隐藏元素的合法用法,那么这就像其他一切一样 - 应该有没问题..事实上,在这种情况下,额外的标头理论上应该可以帮助他们“找到结构” - 所以我真的觉得这不是最大的担忧..

我的想法

我绝对认为我们应该标题部分按照 HTML5 建议,它比任何代码元素或类名称都更具语义,但我也 100% 认为我们应该能够向视觉查看者隐藏它们,因为显示标题“搜索此网站”是没有意义的如果您的视觉用户可以看到那里有一个搜索框;) - 该标题仅对非视觉用户和 SE 有用,可以帮助他们找到文档的区域。理论上,这应该可以帮助 SE/Google 忽略该区域,例如他们应该不需要为搜索框建立索引..所以他们将不得不开始研究他们的人工智能,你不觉得吗;)

我的感觉是同意这一点,并清楚你为什么这样做,那么如果您的网站万一被标记(我认为这极不可能,而且无论如何都会是手动审核),您可以非常清楚地解释为什么要这样做。.只要这些隐藏标题不是“垃圾邮件”,那么我认为它将属于与“图像替换”相同的类别

+1 好问题!

Another, which I've tentatively tried on my site, is to set headings for all sectioning elements and then use CSS to hide the headings for some of theme (again, basically <nav> and <footer>, as well as some <section> elements.

That is exactly the way I would do it, haven't actually had to build an HTML5 site yet, but funnily enough I looked into this a while back.

"headings" or section titles, are great for creating the structure or document outline (as shown on the outliner). They are also very useful for Assisted Technology users, who can basically find their way around a site by "tabbing" through headers without having to "listen to" everything to and try to figure out where you might have put e.g. your search box.

That is the reason why I see that headings/titles should be there, even though they're hidden from visual users view (and stuff the SE's ;))

Not all CSS hiding methods are equal

OK so I know we can't write off the SE's so the way you choose to hide the headers is then important, as you want them to be available to the AT (Assisted technology) users.. display: none; is not reliable (some screen readers don't read them) and you can't "tab" find them either - visibility: hidden; won't remove the space and you still can't "tab" find

So which hiding method?

.. there happens to be a really cool one, discovered by members of the Drupal community.. using the clip: rect(); property which keeps everyone happy

.my-hidden-element {
  position: absolute;
  clip: rect(1px 1px 1px 1px); /* IE6 & 7 */
  clip: rect(1px, 1px, 1px, 1px);
}

As for Google, not only would it be hard for them to "blanket ban/penalise" based on the clip property, even if do start to raise flags, I think it's like everything else if you can prove a legitimate usage for hiding an element - there should be no problem.. and in fact in this case the extra headers should theoretically help them "find structure" too - so I really feel this is not the biggest worry..

My Thoughts

I absolutely think we should title sections as per the HTML5 recs, it's more semantic than any code element or class name, but I also 100% think that we should be able to hide them from visual viewers as there is no point in showing the title "Search this Site" if your visual users can see there's a search box there ;) - that title is only useful to non-visual users and SE's to help them locate areas of the document.. in theory that should help SE's/Google dismiss that area e.g. they shouldn't need to index a search box.. so they're going to have to get to work on their AI, don't you think ;)

My feeling would be to go with this and be clear about why you're doing so, then if your site is by any chance flagged (which I would think would be highly unlikely and would be a manual review anyway) you can explain quite clearly why you're doing it.. As long as those hidden titles aren't "spammy" then I think it will fall into the same category as "image replacement"

+1 Great Question!

遮云壑 2024-11-05 14:02:30

我最喜欢的处理方式。禁用样式后,您会看到标题,但它是一个小标题,而不是 h1。

<nav>
<h6 class="hidden">Navigation</h6>
<ul>
<li><a href="www.ronpaul.com">Ron Paul 2012</a></li>

.hidden{
   position:absolute;
   left:-9999px;
}

或者

.hidden{
   text-indent:-9999px;
}

My preferred way of dealing with it. With styles disabled, you see the heading, but it's a small heading, not an h1.

<nav>
<h6 class="hidden">Navigation</h6>
<ul>
<li><a href="www.ronpaul.com">Ron Paul 2012</a></li>

.hidden{
   position:absolute;
   left:-9999px;
}

OR

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