Complete the code to apply a red text color only to the first item in the list.
<ul> <li class="[1]">First item</li> <li>Second item</li> <li>Third item</li> </ul>
text-red-500 without the first: prefix colors all items.last:text-red-500 colors the last item, not the first.The first: prefix in Tailwind applies styles only to the first child element. Here, first:text-red-500 colors the first list item red.
Complete the code to add a blue background only to the last paragraph inside a section.
<section> <p>Paragraph one</p> <p>Paragraph two</p> <p class="[1]">Paragraph three</p> </section>
bg-blue-500 without the last: prefix colors all paragraphs.first:bg-blue-500 colors the first paragraph, not the last.The last: prefix applies styles only to the last child element. Here, last:bg-blue-500 adds a blue background to the last paragraph.
Fix the error in the code to apply a green border only to the first list item.
<ul> <li class="[1] border-green-500 border-2">Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul>
first: after the style class causes no effect.last:border-green-500 targets the last item, not the first.The correct Tailwind syntax to apply a border only to the first child is first:border-green-500. The prefix first: must come before the style.
Fill both blanks to add padding to the first child and margin to the last child in a div.
<div> <p class="[1]">First paragraph</p> <p class="[2]">Last paragraph</p> </div>
first: or last: prefixes affects all elements.first: and last: prefixes.first:pt-4 adds top padding only to the first child, and last:mb-6 adds bottom margin only to the last child.
Fill all three blanks to style a list: first item with bold text, last item with italic text, and all items with gray text.
<ul class="text-gray-700"> <li class="[1]">First</li> <li>Middle</li> <li class="[2]">Last</li> </ul>
font-bold without first: prefix colors all items bold.italic without last: prefix styles all items italic.The list has gray text by default. first:font-bold makes the first item bold, last:italic makes the last item italic, and font-bold is used for the first itemβs bold style.