PHPnews.io

CSS: Select first x items

Written by Bram.us / Original link on Jun. 21, 2022

html-css-banner.png

Because I keep forgetting this, an entry on the blog so that my future self can find it back easily:

CSS: Want your first 5 list items to be bold?

li:nth-of-type(-n + 5) {font-weight: bold;}

Start with the # of list items you want to impact, then increment backward with -n.

— Estelle Weyl (@estellevw) June 21, 2022

bram tutorialzine calevans selectors bram

« Zoom in on Symfony 5/6: the fast track workshop at SymfonyCon Disneyland Paris 2022 - Add Interfaces to Laravel to Increase Code Readability and Verbosity »