Overview - Global styles
What is it?
Global styles in Svelte are CSS rules that apply to the entire application or webpage, not just to a single component. Unlike component-scoped styles, global styles affect all elements matching the selectors anywhere in the app. They help maintain consistent look and feel across different parts of the app. Global styles are usually defined in a special way to avoid conflicts with Svelte's default style scoping.
Why it matters
Without global styles, every component would need to repeat common styling, leading to inconsistent design and more work. Global styles solve this by letting you define shared styles once, like fonts, colors, or layout rules. This makes your app easier to maintain and ensures a unified user experience. Without global styles, apps would look patchy and be harder to update.
Where it fits
Before learning global styles, you should understand basic CSS and how Svelte scopes styles to components. After mastering global styles, you can explore advanced theming, CSS variables, and CSS frameworks integration in Svelte.