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 is reusable CSS?
Reusable CSS means writing styles that can be used on many elements or pages without rewriting the same code. It saves time and keeps code clean.
Click to reveal answer
beginner
Why use CSS classes for reusability instead of IDs?
Classes can be used on multiple elements, making styles reusable. IDs are unique and should be used only once per page.
Click to reveal answer
intermediate
What is a CSS variable and how does it help reuse?
A CSS variable stores a value (like a color) that you can reuse throughout your styles. Changing it once updates all places using it.
Click to reveal answer
intermediate
How does using utility classes improve CSS reusability?
Utility classes are small, single-purpose classes (like .text-center) that you can combine to style elements quickly without repeating code.
Click to reveal answer
advanced
What is the benefit of separating layout and theme styles in reusable CSS?
Separating layout (structure) and theme (colors, fonts) lets you reuse layout styles with different themes easily, making your CSS flexible.
Click to reveal answer
Which CSS selector is best for reusable styles?
AID selector
BElement selector
CClass selector
DInline style
✗ Incorrect
Class selectors can be applied to many elements, making styles reusable. IDs are unique and inline styles are not reusable.
What does a CSS variable start with?
A$
B@
C#
D--
✗ Incorrect
CSS variables start with two dashes, like --main-color.
Why avoid repeating the same CSS code in multiple places?
AIt makes maintenance harder
BIt improves browser speed
CIt makes the file smaller
DIt is required by CSS rules
✗ Incorrect
Repeating code makes it harder to update styles later because you must change many places.
What is a utility class in CSS?
AA class that applies one small style
BA class that styles the whole page
CA class that is only used once
DA class that uses !important
✗ Incorrect
Utility classes apply a single style, like margin or text alignment, making them easy to reuse.
How can you make colors reusable in CSS?
AUse inline styles
BUse CSS variables
CUse element selectors
DUse !important
✗ Incorrect
CSS variables let you define colors once and reuse them everywhere.
Explain how to write CSS that can be reused on many elements.
Think about how you can write styles once and apply them many times.
You got /4 concepts.
Describe the benefits of separating layout and theme styles in reusable CSS.
Consider how changing colors without touching layout helps.
You got /4 concepts.
Practice
(1/5)
1. What is the main benefit of using reusable CSS classes in web development?
easy
A. You can write styles once and use them many times.
B. It makes the website load slower.
C. It requires writing more code for each element.
D. It only works with inline styles.
Solution
Step 1: Understand the purpose of reusable CSS classes
Reusable CSS classes allow you to write a style rule once and apply it to multiple elements, saving time and effort.
Step 2: Compare options to the main benefit
Options B, C, and D describe drawbacks or incorrect uses, while You can write styles once and use them many times. correctly states the main benefit.
Final Answer:
You can write styles once and use them many times. -> Option A
Quick Check:
Reusable CSS = Write once, use many times [OK]
Hint: Reusable classes save time by reusing styles [OK]
Common Mistakes:
Thinking reusable CSS slows down the site
Confusing reusable classes with inline styles
Believing reusable CSS requires more code
2. Which of the following is the correct syntax to define a reusable CSS class named button?
easy
A. button { color: blue; }
B. #button { color: blue; }
C. .button { color: blue; }
D. *button { color: blue; }
Solution
Step 1: Identify CSS selector for classes
In CSS, classes are selected using a dot (.) before the class name.
Step 2: Match syntax to class selector
.button { color: blue; } uses .button which is correct. #button { color: blue; } uses an ID selector (#), C uses an element selector, and D uses an invalid selector.
Final Answer:
.button { color: blue; } -> Option C
Quick Check:
Class selector starts with dot (.) [OK]
Hint: Class selectors start with a dot (.) in CSS [OK]
Common Mistakes:
Using # instead of . for classes
Omitting the dot before class name
Confusing element selectors with class selectors
3. Given the CSS below, what color will the text inside the <p> tag have?
.red { color: red; } .bold { font-weight: bold; }
Hello World
medium
A. Default browser color
B. Bold only
C. Red only
D. Red and bold
Solution
Step 1: Analyze the applied classes
The paragraph has two classes: red and bold. The red class sets text color to red, and bold sets font weight to bold.
Step 2: Combine effects of both classes
Both styles apply together, so the text will be red and bold.
Final Answer:
Red and bold -> Option D
Quick Check:
Multiple classes combine styles [OK]
Hint: Multiple classes combine their styles on one element [OK]
Common Mistakes:
Thinking only one class style applies
Confusing color and font-weight properties
Ignoring combined class effects
4. What is wrong with this CSS if the goal is to reuse the style for multiple buttons?
B. The element selector button and class .button conflict causing confusion.
C. Class selectors cannot be reused.
D. The CSS syntax is invalid.
Solution
Step 1: Understand selector types
The selector button targets all <button> elements, while .button targets elements with class "button".
Step 2: Identify conflict in styles
The paragraph has class "button" but is not a <button> element, so only .button applies. The similar names can confuse developers.
Final Answer:
The element selector button and class .button conflict causing confusion. -> Option B
Quick Check:
Element and class selectors with same name cause confusion [OK]
Hint: Avoid naming classes same as HTML elements [OK]
Common Mistakes:
Using # instead of . for classes
Assuming class selectors can't be reused
Ignoring selector specificity and conflicts
5. You want to create a reusable CSS class for a card component that has a shadow, padding, and rounded corners. Which CSS snippet correctly combines these styles for reuse?
Classes use a dot (.) before the name, so .card is correct. #card { box-shadow: 0 4px 6px rgba(0,0,0,0.1); padding: 1rem; border-radius: 0.5rem; } uses an ID selector (#), C uses an invalid element selector, and D uses incorrect CSS properties.
Step 2: Verify CSS properties for shadow, padding, and rounded corners
box-shadow, padding, and border-radius are correct CSS properties. .card { shadow: 0 4px 6px rgba(0,0,0,0.1); padding: 1rem; rounded: 0.5rem; } uses invalid properties shadow and rounded.