Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What are fallback values in CSS?
Fallback values are alternative CSS values used when the preferred value is not supported by the browser. They ensure the style still works and looks good.
Click to reveal answer
beginner
How do you write fallback values for the font-family property?
List multiple font names separated by commas. The browser uses the first available font. Example: font-family: Arial, Helvetica, sans-serif;
Click to reveal answer
intermediate
Why use fallback colors in CSS?
Fallback colors ensure text or backgrounds remain visible if a CSS function or variable is unsupported. For example, color: var(--main-color, black); uses black if the variable is missing.
Click to reveal answer
intermediate
Example of fallback for a CSS gradient background?
Use a solid color before the gradient. Example: background: #333; background: linear-gradient(to right, #333, #666); The solid color shows if gradients are unsupported.
Click to reveal answer
intermediate
What is the benefit of using fallback values in responsive design?
Fallback values help maintain usability and appearance on older browsers or devices that don’t support newer CSS features, improving accessibility and user experience.
Click to reveal answer
What happens if a browser does not support the first font in a font-family list?
AIt shows no text
BIt uses the next font in the list
CIt crashes
DIt uses a random font
✗ Incorrect
The browser tries fonts in order until it finds one installed or supported.
Which CSS property example shows a fallback color using a CSS variable?
Acolor: black, var(--main-color);
Bcolor: black | var(--main-color);
Ccolor: var(--main-color, black);
Dcolor: var(--main-color);
✗ Incorrect
The syntax var(--variable, fallback) uses the fallback if the variable is missing.
Why add a solid color before a gradient background?
ATo center the gradient
BTo make the gradient brighter
CTo reduce file size
DTo provide a fallback if gradients are unsupported
✗ Incorrect
The solid color shows on browsers that don’t support gradients.
Which is NOT a reason to use fallback values?
AMake CSS code shorter
BEnsure content visibility
CImprove browser compatibility
DEnhance user experience on old devices
✗ Incorrect
Fallbacks usually add code but improve compatibility and experience.
How do fallback values help with accessibility?
ABy ensuring text and backgrounds remain visible
BBy hiding content on unsupported browsers
CBy disabling keyboard navigation
DBy changing font sizes automatically
✗ Incorrect
Fallbacks keep content readable even if some styles fail.
Explain what fallback values are in CSS and why they are important.
Think about what happens if a browser does not understand a CSS value.
You got /3 concepts.
Describe how to write fallback values for fonts and colors in CSS with examples.
Use commas for fonts and var() with a second argument for colors.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of using fallback values in CSS?
easy
A. To make the website load faster
B. To provide backup styles if the main style is not supported
C. To add animations to elements
D. To change the HTML structure dynamically
Solution
Step 1: Understand fallback values concept
Fallback values are used to ensure styles still apply if the preferred style is unsupported by the browser.
Step 2: Identify the purpose from options
Only To provide backup styles if the main style is not supported correctly describes fallback values as backup styles.
Final Answer:
To provide backup styles if the main style is not supported -> Option B
Quick Check:
Fallback values = backup styles [OK]
Hint: Fallback means backup style if main fails [OK]
Common Mistakes:
Thinking fallback speeds up loading
Confusing fallback with animations
Believing fallback changes HTML
2. Which of the following is the correct way to provide fallback fonts in CSS?
easy
A. font-family: sans-serif 'Open Sans';
B. font-family: 'Open Sans';
C. font-family: Arial 'Open Sans';
D. font-family: 'Open Sans', Arial, sans-serif;
Solution
Step 1: Recall font-family syntax with fallbacks
Fallback fonts are listed separated by commas, from preferred to generic.
Step 2: Check each option's syntax
font-family: 'Open Sans', Arial, sans-serif; correctly lists 'Open Sans', then Arial, then generic sans-serif with commas.
Final Answer:
font-family: 'Open Sans', Arial, sans-serif; -> Option D
Quick Check:
Fallback fonts use commas [OK]
Hint: Separate fallback fonts with commas [OK]
Common Mistakes:
Missing commas between fonts
Wrong order of fonts
Using quotes incorrectly
3. What color will the text be if the browser does not support CSS variables in this code?
p { color: var(--main-color, blue); }
medium
A. Blue
B. The color defined by --main-color variable
C. Black (default color)
D. Transparent
Solution
Step 1: Understand CSS variable fallback syntax
The syntax var(--main-color, blue) means use --main-color if supported, else fallback to blue.
Step 2: Consider browser support for CSS variables
If the browser does not support CSS variables, it uses the fallback value blue.
Final Answer:
Blue -> Option A
Quick Check:
Fallback value used when variable unsupported [OK]
Hint: Fallback after comma used if variable unsupported [OK]
Common Mistakes:
Assuming variable always works
Choosing default black color
Confusing fallback with transparency
4. Identify the error in this CSS fallback usage:
div { background-image: url('image.webp', 'image.png'); }
medium
A. Fallback images require multiple url() functions separated by commas
B. Only one URL is allowed inside url() function
C. The URLs should be separated by commas as shown
D. Fallback images are not supported in CSS
Solution
Step 1: Understand fallback for background images
Fallback images are provided by listing multiple url() functions separated by commas.
Step 2: Analyze the given code
The code incorrectly puts two URLs inside one url() function, which is invalid syntax.
Fallback images require multiple url() functions separated by commas -> Option A
Quick Check:
Multiple url() with commas for fallback [OK]
Hint: Use separate url() calls for fallback images [OK]
Common Mistakes:
Putting multiple URLs inside one url()
Missing commas between url() functions
Thinking fallback images not supported
5. You want to set a CSS variable --primary-color with a fallback to green if the variable is not defined. Which CSS rule correctly applies this fallback to the text color and background-color?
hard
A. color: var(--primary-color, green); background-color: var(--primary-color);
B. color: var(--primary-color); background-color: green;
C. color: var(--primary-color, green); background-color: var(--primary-color, green);
D. color: green; background-color: var(--primary-color, green);
Solution
Step 1: Understand fallback usage for CSS variables
To ensure fallback works for both color and background-color, each var() must include fallback.
Step 2: Analyze each option
color: var(--primary-color, green); background-color: var(--primary-color, green); uses var(--primary-color, green) for both properties, ensuring fallback if variable undefined.
Step 3: Why others are incorrect
color: var(--primary-color, green); background-color: var(--primary-color); misses fallback for background-color; B misses fallback for color; C sets color fixed to green ignoring variable.
Final Answer:
color: var(--primary-color, green); background-color: var(--primary-color, green); -> Option C