Possible Duplicate:
How to skip first child?
I have a ul
with 4 li
in it:
<div id="someid"> <ul> <li>1st</li> <li>2nd</li> <li>3rd</li> <li>4th</li> </ul> </div>
I'm setting a style for these li
elements:
#someid ul li{ font-weight: bold; }
Now I want exclude the first li
. How can I do it?
By using the :not(:first-child) selector, you remove that problem. You can use this selector on every HTML element.
The :first-child selector is used to select the specified selector, only if it is the first child of its parent.
The :first-child pseudo class means "if this element is the first child of its parent". :last-child means "if this element is the last child of its parent". Note that only element nodes (HTML tags) count, these pseudo-classes ignore text nodes.
#someid ul li:not(:first-of-type) { font-weight: bold; }
or if that doesn't work in ancient browsers:
#someid ul li { font-weight: bold; } #someid ul li:first-child { font-weight: normal; }
Use the CSS first-child selector:
#someid ul li:first-child { font-weight: normal; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With