Computerhelp4all logo Articles AboutTopicsQuizzesComputer Questions & AnswersComputer Terms & DefinitionsActivitiesContact

What Is The Data-Nosnippet Attribute?

What Is The Data-Nosnippet Attribute

Date First Published: 18th November 2022

Topic: Web Design & Development

Subtopic: SEO

Article Type: Computer Terms & Definitions

Difficulty: Medium

Difficulty Level: 6/10

Learn more about what the data-nosnippet attribute is in this article.

Not to be confused with the nosnippet tag.

The data-nosnippet attribute is a HTML attribute used to instruct Google to not use certain textual parts of a HTML page as a featured snippet and a description under the search engine listing. Text found in elements marked with the data-nosnippet attribute with valid HTML and closing tags will not be used as a snippet in the Google search results page. This can be accomplished by adding the attribute to <div>, <span>, and <section> elements. This HTML attribute is different from the nosnippet tag, which is inserted in the head of the HTML document and completely prevents search engines from showing a featured or regular description under the search engine listing, not just certain text. An example of the data-nosnippet attribute can be seen below:

<div data-nosnippet>Do not include this text in the snippet.</div>

It is not recommended to add or remove the data-nosnippet attribute of existing nodes using JavaScript as this will cause uncertainty when Google renders the page. When using JavaScript to add DOM elements, always include the data-nosnippet attribute when originally adding the element to the DOM of the page.


Note: Info Icon

Similar to the noindex tag instruction, in order for the data-nosnippet instruction to be effective, the page must not be blocked by the robots.txt file. If the web crawler is blocked by the robots.txt file or cannot access the page, the crawler won't see the data-nosnippet instruction and the text can appear as a snippet under the search engine listing.


Note: Info Icon

If an element a website owner is setting to data-nosnippet is already in the search results as a snippet, it might take some time for the text to disappear from the search results as search engine bots will have to recrawl the page to see the data-nosnippet attribute.

Why Would Website Owners Use The Data-Nosnippet Attribute?

Usually, search engine bots automatically choose the most relevant piece of text as a description in the search results or the description can be specified in the meta description tag. Sometimes, website owners want to have a description under their search engine listing, but there are just some pieces of text that they do not want to appear under the search result. The types of text that website owners may not want search engine bots to appear are:

  • Sensitive information that they don’t want search engine bots to create a description of under the search engine listing.
  • Advertising they don’t want search engines to create a description of.


Feedback

  • Is there anything that you disagree with on this page?
  • Are there any spelling, grammatical, or punctuation errors on this page?
  • Are there any broken links or design errors on this page?

If so, it is important that you tell me as soon as possible on this page.