如何在搜索引擎结果中隐藏图标字体?

时间:2019-04-03 09:15:16

标签: html css fonts icons seo

我在html中用于显示图标字体图标的文字出现在Google搜索结果中。我该如何阻止这种情况的发生?

我已经添加了area-hiddenrole='img',但是这些似乎没有任何影响。

<span class="material-icons" aria-hidden="true" role="img">search</span>

我在网上环顾四周,大部分发现的信息是有关如何为可访问性目的而进行改进的,而不是关于如何将其隐藏在googlebot中的信息。

解决方案

基于下面的@jake回答,我进行了以下尝试。

HTML

<span class="material-icons" aria-hidden="true" role="img" data-icon="search"></span>

CSS

.material-icons::after{
    content: attr(data-icon);
}

1 个答案:

答案 0 :(得分:1)

question提供了伪元素形式的答案。

在这个github线程上,他们建议使用字体代码点:
https://github.com/google/material-design-icons/issues/498

检查代码点和图标之间的mapping