3. What will be the computed background color of the <div> in this CSS using future CSS variables?
:root { --main-color: coral; } div { background-color: var(--main-color); }
medium
A. var(--main-color)
B. transparent
C. black
D. coral
Solution
Step 1: Identify the variable definition
The variable --main-color is set to coral in the :root selector, making it global.
Step 2: Apply the variable in div
The div uses background-color: var(--main-color); which fetches the value coral.
Final Answer:
coral -> Option D
Quick Check:
CSS variable value applied = coral [OK]
Hint: var() fetches the value of CSS custom properties [OK]
Common Mistakes:
Thinking var() outputs the variable name
Assuming default color if variable is defined
Confusing transparent with variable usage
4. Identify the error in this future CSS code snippet that tries to use nesting:
section { article { padding: 1rem; } }
medium
A. Nesting must use & or :is() or :where()
B. The ampersand (&) is not supported in future CSS nesting
C. Incorrect property name 'padding'
D. Missing semicolon after padding value
Solution
Step 1: Check nesting syntax in future CSS
Future CSS requires nested selectors to start with & or pseudo-classes like :is() or :where(). Plain article is invalid.
Step 2: Identify correct nesting method
Correct would be section { & article { padding: 1rem; } } or using pseudo-classes.
Final Answer:
Nesting must use & or :is() or :where() -> Option A
Quick Check:
Future CSS nesting requires & or pseudo-classes [OK]
Hint: Future CSS nesting requires & or :is()/:where() [OK]
Common Mistakes:
Using plain selectors without & or pseudo-class
Ignoring missing semicolon which is correct here
Confusing property names
5. You want to create a responsive design using future CSS features replacing SASS. Which is the correct way to write a media query that changes font size for screens wider than 600px?
medium
A. @media screen and (min-width: 600px) { body { font-size: 1.2rem; } }
B. @media (min-width: 600px) { body { font-size: 12; } }
C. @media screen (min-width: 600px) { body { font-size: 1.2rem; } }
D. @media (min-width: 600) { body { font-size: 1.2rem; } }
Solution
Step 1: Understand media query syntax
Future CSS uses standard CSS media queries. The correct syntax includes the media type, e.g., screen and (min-width: 600px).
Step 2: Check font size units
Using 1.2rem is better for accessibility and scaling than fixed pixels.
Final Answer:
@media screen and (min-width: 600px) { body { font-size: 1.2rem; } } -> Option A
Quick Check:
Media query with screen and rem units [OK]
Hint: Always include media type and use rem units for fonts [OK]