0
0
Tailwindmarkup~5 mins

First-child and last-child targeting in Tailwind - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the <code>:first-child</code> CSS pseudo-class select?
It selects the very first child element inside its parent container.
Click to reveal answer
beginner
How do you target the last child element using Tailwind CSS?
Use the last: variant before a utility class, for example, last:bg-blue-500 changes the background of the last child.
Click to reveal answer
beginner
Why is targeting first-child and last-child useful in web design?
It helps style only the first or last item differently, like adding extra space or a special color, making lists or menus look neat and clear.
Click to reveal answer
intermediate
How would you add a top border only to the first item in a list using Tailwind?
Use first:border-t on the list items to add a top border only to the first child.
Click to reveal answer
intermediate
What is the difference between :first-child and :first-of-type selectors?
:first-child selects the first child regardless of type, while :first-of-type selects the first child of a specific element type.
Click to reveal answer
Which Tailwind prefix targets the last child element?
Alast:
Bfirst:
Cchild-last:
Dend:
What does first:bg-red-500 do in Tailwind?
AColors the last child background red
BColors the first child background red
CColors all children red
DColors the parent background red
Which CSS pseudo-class selects the last child element?
A:last-child
B:first-child
C:nth-child(1)
D:only-child
If you want to add margin only to the first item in a list using Tailwind, which prefix do you use?
Aonly:
Blast:
Cfirst:
Dchild:
What happens if you use last:border-b-2 on list items?
AAdds a bottom border to all items
BAdds a top border to the last item
CRemoves bottom border from last item
DAdds a bottom border only to the last item
Explain how you would style the first and last items in a navigation menu differently using Tailwind CSS.
Think about how to add different colors or spacing to the first and last menu items.
You got /4 concepts.
    Describe the difference between the CSS selectors :first-child and :last-child and how Tailwind helps you use them.
    Focus on what each selector targets and how Tailwind makes it easy to apply styles.
    You got /4 concepts.