A card component is a container that groups related information visually, like a small box with content such as images, text, and buttons. It helps users scan and understand content easily.
Click to reveal answer
beginner
Which Tailwind CSS utility classes help create a card with shadow and rounded corners?
Use shadow-lg for shadow and rounded-lg for smooth rounded corners. These classes make the card look lifted and friendly.
Click to reveal answer
intermediate
How can you make a card responsive using Tailwind CSS?
Use responsive utilities like sm:, md:, lg: to adjust padding, width, or layout. For example, w-full md:w-1/3 makes the card full width on small screens and one-third width on medium screens.
Click to reveal answer
beginner
Why should you use semantic HTML elements inside a card?
Semantic elements like <article>, <header>, and <footer> improve accessibility and help screen readers understand the content structure better.
Click to reveal answer
intermediate
What Tailwind classes help create a card layout with image on top and text below?
Use flex flex-col to stack content vertically. Place the image inside a <img> tag with rounded-t-lg for rounded top corners, and text inside a p-4 padded container below.
Click to reveal answer
Which Tailwind class adds a shadow effect to a card?
Ashadow-lg
Brounded-full
Cbg-gray-100
Dtext-center
✗ Incorrect
The class shadow-lg adds a large shadow to create depth on the card.
What does the Tailwind class rounded-lg do to a card?
AAdds a border
BAdds padding inside the card
CCenters the text
DRounds the corners of the card
✗ Incorrect
rounded-lg makes the corners of the card smoothly rounded.
How can you make a card take full width on small screens and one-third width on medium screens using Tailwind?
Aw-1/3 sm:w-full
Bw-full lg:w-1/2
Cw-full md:w-1/3
Dw-1/2 md:w-full
✗ Incorrect
Using w-full md:w-1/3 sets full width on small and one-third width on medium screens.
Which semantic HTML element is best to wrap a card's main content?
A<div>
B<article>
C<span>
D<section>
✗ Incorrect
<article> is used for self-contained content like a card.
What Tailwind classes would you use to stack an image above text inside a card?
Aflex flex-col
Bgrid grid-cols-2
Cflex flex-row
Dinline-block
✗ Incorrect
flex flex-col stacks children vertically, placing image above text.
Describe how to build a simple card component using Tailwind CSS that includes an image, title, and description.
Think about container styling and layout direction.
You got /4 concepts.
Explain why semantic HTML and accessibility are important when creating card components.
Consider users who rely on assistive technologies.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a card component in web design using Tailwind?
easy
A. To add background music to a website section
B. To create complex animations on a webpage
C. To replace the entire page layout with a single element
D. To group related content like images, text, and buttons in a neat box
Solution
Step 1: Understand the role of card components
Cards are designed to group related content visually, such as images, text, and actions, making information easy to scan.
Step 2: Identify the correct purpose
Options A, B, and C describe unrelated or incorrect uses of cards in web design.
Final Answer:
To group related content like images, text, and buttons in a neat box -> Option D
Quick Check:
Card purpose = Group related content [OK]
Hint: Cards group content visually in boxes [OK]
Common Mistakes:
Thinking cards are for animations
Confusing cards with page layout containers
Assuming cards add multimedia like music
2. Which Tailwind class correctly adds padding inside a card component?
easy
A. p-4
B. m-4
C. text-center
D. bg-gray-200
Solution
Step 1: Understand Tailwind padding classes
The class p-4 adds padding inside an element, creating space between content and edges.
Step 2: Differentiate from other classes
m-4 adds margin outside the element, text-center centers text, and bg-gray-200 sets background color.
Final Answer:
p-4 -> Option A
Quick Check:
Padding inside card = p-4 [OK]
Hint: Padding starts with 'p-', margin with 'm-' [OK]
Common Mistakes:
Confusing padding (p-) with margin (m-)
Using text alignment instead of spacing
Mixing background color with spacing classes
3. What will be the visual effect of this Tailwind card code snippet?
The img tag lacks an alt attribute, which is important for screen readers to describe the image.
Step 2: Review other options
Button hover effects and background colors are style choices, not accessibility requirements. Padding on the button is valid.
Final Answer:
The img tag is missing an alt attribute -> Option B
Quick Check:
Missing alt attribute = accessibility issue [OK]
Hint: Always add alt text to images for accessibility [OK]
Common Mistakes:
Ignoring missing alt attributes on images
Confusing style issues with accessibility
Assuming padding errors cause accessibility problems
5. You want to create a responsive card grid using Tailwind that shows 1 column on small screens and 3 columns on large screens. Which class combination achieves this?
hard
A. grid grid-cols-1 lg:grid-cols-3 gap-6
B. flex flex-col lg:flex-row gap-6
C. block lg:grid-cols-3 gap-6
D. grid-cols-3 grid gap-6 lg:grid-cols-1
Solution
Step 1: Understand responsive grid classes
grid-cols-1 sets 1 column by default (small screens), and lg:grid-cols-3 changes to 3 columns on large screens. gap-6 adds spacing between grid items.
Step 2: Evaluate other options
flex flex-col lg:flex-row gap-6 uses flex layout, which can work but does not define columns explicitly. block lg:grid-cols-3 gap-6 uses block which disables grid. grid-cols-3 grid gap-6 lg:grid-cols-1 reverses column counts incorrectly.