Skip to main content
Basic Svelte
Introduction
Reactivity
Props
Logic
Events
Bindings
Classes and styles
Actions
Transitions
Advanced Svelte
Advanced reactivity
Reusing content
Motion
Advanced bindings
Advanced transitions
Context API
Special elements
<script module>
Next steps
Basic SvelteKit
Introduction
Routing
Loading data
Headers and cookies
Shared modules
Forms
API routes
$app/state
Errors and redirects
Advanced SvelteKit
Hooks
Page options
Link options
Advanced routing
Advanced loading
Environment variables
Conclusion

Just like in HTML, you can add a <style> tag to your component. Let’s add some styles to the <p> element:

App
<p>This is a paragraph.</p>

<style>
	p {
		color: goldenrod;
		font-family: 'Comic Sans MS', cursive;
		font-size: 2em;
	}
</style>

Importantly, these rules are scoped to the component. You won’t accidentally change the style of <p> elements elsewhere in your app, as we’ll see in the next step.

Edit this page on GitHub

1
2
3
4
5
6
<p>This is a paragraph.</p>
 
<style>
	/* Write your CSS here */
</style>