Complete the code to import a CSS file in an Astro component.
--- import '[1]'; --- <div>Hello Astro!</div>
Astro imports CSS files directly using the import statement with the CSS file path.
Complete the code to add scoped styles inside an Astro component.
<style [1]> p { color: blue; } </style> <p>This text is blue and scoped.</p>
global which applies styles globally.module or local.Using scoped attribute in Astro's <style> tag scopes styles to the component only.
Identify the CSS import that causes unused CSS to load unnecessarily.
--- import '[1]'; --- <div>Content without styles</div>
Astro includes all imported CSS by default, even if unused. Importing ./unused.css causes unnecessary loading since the component has no matching elements.
Fill both blanks to create a style block that applies globally and one scoped style.
<style [1]> body { margin: 0; } </style> <style [2]> h1 { color: red; } </style>
The first style block uses global to apply styles to the whole page. The second uses scoped to limit styles to the component.
Fill all three blanks to create a style object with dynamic class names and conditional styles in Astro.
---
const isActive = true;
const styles = {
button: '[1]',
active: isActive ? '[2]' : '',
disabled: '[3]'
};
---
<button class="{styles.button} {styles.active} {styles.disabled}">Click me</button>Class names are assigned dynamically. button uses btn, active uses btn-active if active, and disabled uses btn-disabled.