Organize stylesheet source with Sass features and compile it into CSS.

Before starting: HTML and CSS selectors, spacing, and responsive design.

Practice project: Compile and explain a small reusable stylesheet.

Foundation and first practice

  1. Compile a small Sass stylesheet

    Sass is a stylesheet language that compiles to CSS. Browsers consume the generated CSS, not the SCSS source. Start with one variable and a shallow nested selector so you can predict the compiled result. Deep nesting can create unnecessarily specific selectors and make overrides harder to reason about.

    Dart Sass command-line compiler; SCSS syntax

    $accent: #075985;
    
    .study-card {
      color: $accent;
      a {
        text-decoration: underline;
      }
    }
    Check the output
    The CSS contains .study-card { color: #075985; } and .study-card a { text-decoration: underline; }. Formatting may vary.

    Change the accent variable. Explain why the browser needs the regenerated CSS before the change becomes visible.

Open the Sass learning path on DevStudyHub · Play coding games on this blog

logoblog

No comments:

Post a Comment

Please do not enter any spam link in the comment box.