tezvyn:

Svelte Scoped Styles: CSS That Can't Leak

Source: svelte.devbeginner

Svelte styles are like house rules; they only apply inside that component and don't affect the neighbors. This is the default for any `<style>` tag in a `.svelte` file, preventing CSS conflicts.

Svelte styles are like house rules; they only apply inside that component and don't affect the neighbors. It works by automatically adding a unique class to your elements. This is the default for any `<style>` tag in a `.svelte` file, preventing CSS conflicts between components, even for animations. The footgun: this added class increases CSS specificity, so a component's simple `p` selector will unexpectedly override a global `p` style, breaking the normal cascade order you might expect.

Read the original → svelte.dev

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Svelte Scoped Styles: CSS That Can't Leak · Tezvyn