JavaScript rendering · JavaScript content and links
Content inside shadow DOM
Two paragraphs on this page live inside a shadow root created by a script, so crawlers that do not flatten shadow DOM may not see the text.
How this page is built
The custom shadow-note element below is empty in the raw HTML. A script defines it and attaches an open shadow root holding two paragraphs.
Why it matters
Shadow DOM keeps a component’s markup and styles separate from the rest of the page. That is useful for building components, but the content inside is not part of the ordinary document. Google flattens shadow roots into the rendered HTML, so it usually sees the text. Crawl tools and other search engines may not.
Web components built with shadow DOM are increasingly common in design systems, so whole sections of a site can be affected.
How to check it
Open the rendered HTML in a crawl tool that renders JavaScript and search for a sentence from inside the component. In the browser’s developer tools, the shadow root appears as #shadow-root under the custom element. Google’s URL Inspection tool shows whether the text appears in the rendered HTML it saw.
How to fix it
Put text that matters for search in the light DOM, and use slots to place it inside the component. Declarative shadow DOM, written in the HTML, also lets the server send the content in the first response.