diff --git a/ShadowDOM/explainer.md b/ShadowDOM/explainer.md index 8f1d9f8c..3bf439db 100644 --- a/ShadowDOM/explainer.md +++ b/ShadowDOM/explainer.md @@ -83,7 +83,118 @@ This document explores several proposals that would allow developers to apply st ## Non-goals Some developers have expressed interest in CSS selectors crossing through the Shadow DOM, as discussed in [issue 909](https://github.com/WICG/webcomponents/issues/909#issuecomment-1977487651). While this scenario is related to sharing styles with Shadow DOM elements, it is solving a different problem and should be addressed separately. -## Use case +## Use case +### Pages with sub-sections +In some web pages with sub-sections that feature unique CSS styles distinct from the rest of the page, a combination of inherited global styles and highly specific CSS is used, which applies only to those sub-sections. The regular HTML structure often forces the browser to process CSS before rendering the first visual elements. When there is a significant number of styles, it can negatively impact page performance. Due to the limitations in style sharing with Declarative Shadow DOM, web authors cannot selectively share styles between the parent document and shadow roots. Here is an example of a web page with global, shared and unique styles: + +![image](images/webpagewithsubsection.png) + +In this example, CSS variables such as `--font-family` and `--text-color` were added to the global styles, which are used in the main document and within the shadow DOM. + +```html +
+ + + + + +This section uses the global styles defined in the document.
+