Using the Last-Child Selector
When attempting to target the final li element within a specific ul, one might naturally consider employing the :last-child selector. However, it is important to note that this pseudo-class has limited browser support, particularly in older versions of Internet Explorer and Safari.
In such instances, a reliable alternative is to explicitly designate the last li using a dedicated class, such as last-child. This allows you to target it specifically with CSS:
li.last-child { border-bottom: 1px solid #b5b5b5; }
This approach ensures cross-browser compatibility and effectively highlights the last li, as intended.
The above is the detailed content of How Can I Reliably Style the Last List Item in All Browsers?. For more information, please follow other related articles on the PHP Chinese website!