0 day streak
javascript / beginner
Snippet

Scoped Component Styles

CSS inside a Svelte component is automatically scoped. This means the 'p' selector here only affects paragraphs within this specific file, preventing style leaks.

snippet.js
javascript
1
2
3
4
5
6
7
8
<p>Svelte styles are scoped.</p>
<style>
p {
color: purple;
font-weight: bold;
}
</style>
svelte
Breakdown
1
<style>
Defines a style block that Svelte will process to apply local scoping.