Script, markup, and style sections in Svelte
📖 Scenario: You are creating a simple Svelte component to display a greeting message with some styled text.
🎯 Goal: Build a Svelte component that uses the <script> section to define a variable, the markup section to display it, and the <style> section to add color and font size.
📋 What You'll Learn
Create a
<script> section with a variable greeting set to 'Hello, Svelte!'Use the markup section to display the
greeting variable inside an <h1> tagAdd a
<style> section that colors the <h1> text blue and sets the font size to 2remEnsure the component structure follows Svelte conventions with exactly one
<script>, one markup root, and one <style> section💡 Why This Matters
🌍 Real World
Svelte components are used to build interactive web pages with clean separation of logic, markup, and styles.
💼 Career
Understanding Svelte's component structure is essential for frontend developers working with modern web frameworks.
Progress0 / 4 steps