1813 1548 1425 1442 1436 1549 1929 1578 1790 1000 1639 1593 1783 1782 1510 1896 1449 1875 1903 1086 1500 1200 1214 1037 1732 1524 1948 1380 1352 1437 1769 1894 1462 1566 1758 1710 1094 1195 1949 1498 1836 1391 1792 1849 1535 1270 1520 1122 1697 1294 1628 1785 1819 1891 1859 1998 1813 1610 1539 1289 1773 1078 1949 1663 1388 1324 1883 1937 1112 1507 1233 1443 1016 1255 1698 1141 1850 1756 1364 1700 1651 1083 1903 1311 1131 1333 1448 1292 1561 1507 1662 1184 1382 1166 1033 1028 1745 1190 1068 A Previous Sibling Selector | PHPnews.io

PHPnews.io

A Previous Sibling Selector

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

prev-sibling-selector-desired.png

Jim Nielsen set out to style a bunch of links that appeared before hr elements. As the element tree – generated from a Markdown file – was entirely flat, there are no enclosing section elements to hook onto in order to select those links (using something like section p:last-child a:only-child).

The solution? The :has() selector:

p:has(+ hr) a:only-child {
}

This, again, proves that the :has() selector is way more than just a parent selector.

A Previous Sibling Selector →

bram link tutorialzine selectors bram

«  m-cli – Swiss Army Knife for macOS - Complete the Round Trip »