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 the utility-first approach in CSS?
It is a way to style web pages by using many small, single-purpose classes directly in HTML to control layout and appearance, instead of writing big CSS rules.
Click to reveal answer
beginner
How does traditional CSS differ from utility-first CSS?
Traditional CSS uses separate style rules written in CSS files targeting elements or classes, while utility-first CSS applies many small classes directly in HTML to style elements quickly.
Click to reveal answer
beginner
What is one advantage of utility-first CSS?
It helps build designs faster by reusing small classes and reduces the need to write custom CSS, making changes quicker and easier.
Click to reveal answer
intermediate
What is a common challenge when using utility-first CSS?
HTML can become cluttered with many classes, which might be harder to read or maintain for some developers.
Click to reveal answer
beginner
Give an example of a utility class in Tailwind CSS and its effect.
The class text-center centers the text inside an element horizontally.
Click to reveal answer
Which of the following best describes utility-first CSS?
AUsing many small classes in HTML to style elements
BWriting large CSS files with complex selectors
CStyling only with inline styles
DUsing JavaScript to style elements dynamically
✗ Incorrect
Utility-first CSS uses many small, single-purpose classes directly in HTML to style elements.
In traditional CSS, where are styles usually written?
ADirectly inside HTML elements as classes
BIn separate CSS files or style tags
COnly in JavaScript files
DInside image files
✗ Incorrect
Traditional CSS styles are written in separate CSS files or inside style tags in HTML.
What is a potential downside of utility-first CSS?
AIt requires writing more CSS files
BIt only works with JavaScript frameworks
CIt does not support responsive design
DHTML can become cluttered with many classes
✗ Incorrect
Utility-first CSS can make HTML look crowded because of many small classes.
Which Tailwind class would you use to add margin on all sides?
Am-4
Bp-4
Ctext-center
Dbg-blue-500
✗ Incorrect
The class m-4 adds margin on all sides in Tailwind CSS.
Why might developers prefer utility-first CSS for rapid prototyping?
ABecause it requires no HTML changes
BBecause it uses fewer classes
CBecause it allows quick styling by adding classes directly in HTML
DBecause it disables CSS caching
✗ Incorrect
Utility-first CSS lets developers quickly style elements by adding small classes directly in HTML.
Explain the main differences between utility-first CSS and traditional CSS.
Think about where styles live and how they are applied.
You got /4 concepts.
Describe one advantage and one challenge of using utility-first CSS.
Consider speed and code readability.
You got /2 concepts.
Practice
(1/5)
1. What is the main idea behind the utility-first CSS approach?
easy
A. Avoid using any classes and rely only on browser default styles
B. Write all styles in a separate CSS file and link it to HTML
C. Use inline styles inside HTML tags for all styling
D. Use small, single-purpose classes directly in HTML to style elements quickly
Solution
Step 1: Understand utility-first CSS concept
Utility-first CSS means applying many small classes directly in HTML to style elements quickly without writing separate CSS rules.
Step 2: Compare with other options
Options B and C describe traditional CSS and inline styles, which are different from utility-first. Avoid using any classes and rely only on browser default styles is incorrect as it ignores styling.
Final Answer:
Use small, single-purpose classes directly in HTML to style elements quickly -> Option D
Quick Check:
Utility-first = small classes in HTML [OK]
Hint: Utility-first means styling with many small classes in HTML [OK]
Common Mistakes:
Confusing utility-first with inline styles
Thinking utility-first requires separate CSS files
Believing utility-first avoids using classes
2. Which of the following is the correct way to add a Tailwind utility class for padding of 4 units?
easy
A. <div class='padding-4'></div>
B. <div class='p-4'></div>
C. <div class='pad-4'></div>
D. <div class='padding4'></div>
Solution
Step 1: Recall Tailwind padding syntax
Tailwind uses short utility classes like p-4 for padding of 4 units.
Step 2: Check each option
Options A, B, and D use incorrect class names not recognized by Tailwind.
Final Answer:
<div class='p-4'></div> -> Option B
Quick Check:
Padding 4 in Tailwind = p-4 [OK]
Hint: Tailwind uses short class names like p-4 for padding [OK]
Common Mistakes:
Using full words like 'padding' instead of shorthand
Adding numbers without dash (e.g., padding4)
Confusing Tailwind with traditional CSS class names
But the text is not centered in the browser. What is the likely problem?
medium
A. Tailwind CSS file is not linked or loaded properly
B. The class text-center is misspelled
C. The bg-red-500 class removes text centering
D. Padding p-4 prevents text centering
Solution
Step 1: Verify class correctness
The class text-center is spelled correctly and should center text.
Step 2: Consider CSS loading
If styles don't apply, the Tailwind CSS file might not be linked or loaded, causing no styling effect.
Final Answer:
Tailwind CSS file is not linked or loaded properly -> Option A
Quick Check:
Missing CSS file = no styles applied [OK]
Hint: Check if Tailwind CSS file is loaded when styles don't apply [OK]
Common Mistakes:
Blaming utility classes for layout issues
Ignoring missing or wrong CSS file links
Assuming padding affects text alignment
5. You want to create a responsive card with a shadow and rounded corners using Tailwind. Which combination of classes correctly applies these styles and also adds a hover effect to increase shadow intensity?
hard
A. <div class='shadow rounded-none hover:shadow-lg p-6'>Card</div>
B. <div class='box-shadow rounded hover:shadow-xl p-6'>Card</div>
C. <div class='shadow-sm rounded hover:shadow-lg p-6'>Card</div>
D. <div class='shadow-md rounded-full hover:shadow-2xl p-6'>Card</div>
Solution
Step 1: Identify correct shadow and rounded classes
Tailwind uses shadow-sm, shadow, shadow-md, etc. for shadows. rounded adds normal rounded corners.
Step 2: Check hover shadow intensity
Hover classes like hover:shadow-lg increase shadow on hover. <div class='shadow-sm rounded hover:shadow-lg p-6'>Card</div> uses shadow-sm with hover:shadow-lg, a common pattern for subtle to stronger shadow on hover.
Step 3: Evaluate other options
<div class='shadow rounded hover:shadow-lg p-6'>Card</div> uses shadow but no size specified; <div class='box-shadow rounded hover:shadow-xl p-6'>Card</div> uses invalid box-shadow class; <div class='shadow-md rounded-full hover:shadow-2xl p-6'>Card</div> uses rounded-full which makes circle corners, not typical card style.
Final Answer:
<div class='shadow-sm rounded hover:shadow-lg p-6'>Card</div> -> Option C
Quick Check:
shadow-sm + hover:shadow-lg = subtle to strong shadow on hover [OK]
Hint: Use shadow-sm with hover:shadow-lg for subtle to stronger shadow [OK]