In practice, the first paragraph gets blue text, the last gets red text, and the middle stays default. What best explains this behavior?
medium
A. The first: and last: classes must be on the same element but only one applies per element.
B. Tailwind's first: and last: only work if all siblings share the same class.
C. The first: and last: classes must be on the parent, not children.
D. The first: and last: classes must be on each paragraph without repeating.
Solution
Step 1: Understand how first: and last: work on the same element
When both first: and last: are on the same element, only one can apply because an element cannot be both first and last child simultaneously.
Step 2: Analyze the HTML structure
Each paragraph has both classes. Intro is first child, so first:text-blue-700 applies but last:text-red-700 does not. Summary is last child, so last:text-red-700 applies but first: does not. Content matches neither.
Final Answer:
The first: and last: classes are on the same element but only one applies per element. -> Option A
Quick Check:
One element can't be both first and last child [OK]
Hint: One element can only be first or last child, not both [OK]
Common Mistakes:
Thinking classes must be on parent
Believing all siblings must share classes
Expecting both styles on same element
5. You have a navigation bar with 5 links inside a <nav>. You want the first link to have a green border, the last link to have a red border, and all others to have a gray border. Which Tailwind classes and structure will achieve this best?