Does Google's data-nosnippet break the convention for the “data-” attribute prefix? Is it the first to do so?

。_饼干妹妹 提交于 2019-12-21 04:32:06

问题


Today, in a blog post entitled More options to help websites preview their content on Google Search, Google announced new behaviour for the Google search engine. The part that interests me is that Googlebot will now interpret the HTML attribute data-nosnippet like this:

A new way to help limit which part of a page is eligible to be shown as a snippet is the "data-nosnippet" HTML attribute on span, div, and section elements. With this, you can prevent that part of an HTML page from being shown within the textual snippet on the [Google search engine results page].

For example:

<p><span data-nosnippet>Harry Houdini</span> is undoubtedly the most famous magician ever to live.</p>

I am surprised that they chose to use an attribute beginning with the prefix data-. This is what the HTML living standard by WHATWG says about data- attributes (emphasis mine):

A custom data attribute is an attribute in no namespace whose name starts with the string "data-" [...]

Custom data attributes are intended to store custom data, state, annotations, and similar, private to the page or application, for which there are no more appropriate attributes or elements.

As a web developer, I always thought that the point of the data- prefix was to give web developers a namespace intended just for their CSS and scripts to manipulate. A custom HTML attribute without the data- prefex is not future-proof, it may suddenly have meaning in browsers of the future or in search engine bots of the future.

It looks like Googlebot is breaking this convention, and is now choosing to look for and interpret the data-nosnippet HTML attribute. As web developers, we can no longer be confident that data- attributes are "private to the page or application", maybe Google will do this again for another data- attribute in the future!

  • Is my interpretation correct?
  • Is Googlebot the first to interpret data- attributes this way, or has the ship sailed and are browsers and bots interpreting data- attributes already?

来源:https://stackoverflow.com/questions/58096795/does-googles-data-nosnippet-break-the-convention-for-the-data-attribute-pref

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!