Below is a simplification of what an article page on this website could look like. .rich-text provides very nice rich text styles for blog and docs articles.
The problem anyone runs into when approaching a page structure like this is that the .rich-text styles sneak into your preciously styled components that you don't want polluted with other styles. When coding vanilla CSS we're completely at the mercy of the cascade™️, so we need to be mindful of what styles flow where.
But what if we could tell CSS to just... look the other way and not care about our custom, precious components? 🤷
Developers have been quite confused by @scope ever since it was announced believing CSS finally solved style scoping, but no that's not it. Basically @scope is primarily about defining a boundary for where your styles should apply, and depending on how creative you get with the selectors you can do some pretty cool stuff. If that meant absolutely nothing to you, don't worry - you will get the hang of it soon. Keep reading.
TIP
Read through the MDN docs for more comprehensive info. It's actually quite good.
If we introduce a second class, let's call it .not-rich-text, we can use @scope to create a little fence around the elements we want to protect.
Notice how the text styles are different from the ones in the article around the code example component! There are no margins on the any of them, for instance. Our little style fence works!