{
"$schema": "../schemas/code-crispies-module-schema.json",
"id": "units-variables",
"title": "CSS Units & Variables",
"description": "Understand the variety of CSS measurement units and how to define and use custom properties for maintainable styles.",
"difficulty": "beginner",
"lessons": [
{
"id": "units-1",
"title": "Absolute vs. Relative Units",
"description": "Learn the difference between px, rem, em, %, and vw/vh for flexible, responsive layouts.
width: 80%; /* relative to parent */\nmax-width: 40rem; /* relative to root font */\npadding: 16px; /* fixed pixels */", "task": "Set the width of .box to 80% and max-width to 40rem.", "previewHTML": "
:root {\n --main-color: mediumpurple;\n}\n.themed {\n border-color: var(--main-color);\n}",
"task": "Create a --main-color variable in :root with mediumpurple and apply it as the border color on .themed.",
"previewHTML": "width: calc(100% - 2rem);\nmin-height: calc(10vh + 1rem);", "task": "Set the width of .sized to calc(100% - 2rem) and min-height to calc(10vh + 1rem).", "previewHTML": "
width: 50vw; /* 50% of viewport width */\nheight: 20vh; /* 20% of viewport height */", "task": "Give .view a width of 50vw and height of 20vh.", "previewHTML": "