Global styles in Svelte
📖 Scenario: You are building a simple webpage using Svelte. You want to apply some styles that affect the entire page, like setting the background color and font for all text.
🎯 Goal: Create global CSS styles in a Svelte project that set the background color to light gray and the font family to Arial for the whole page.
📋 What You'll Learn
Create a Svelte component with a
<style> blockUse the
:global selector to apply styles globallySet the
body background color to #f0f0f0Set the
body font family to Arial, sans-serifAdd a simple
<h1> heading to see the styles applied💡 Why This Matters
🌍 Real World
Global styles let you set consistent look and feel for your whole website or app, like fonts and background colors.
💼 Career
Knowing how to apply global styles in Svelte is important for frontend developers to maintain consistent design across components.
Progress0 / 4 steps