CSS first-child pseudo class with unordered list (Bootstrap)
I am trying to render a background color on the list item that is the first child of the unordered list.
HTML structure is as follows
and to apply the background color on the first child element I did
It renders orange background to all list items. I’ve played with slight variations but it doesn’t make difference.
.nav-collapse > ul.nav:first-child .nav-collapse > ul:first-child
Use the following:
You were trying to style the first
.nav item - which there is only one of. Simply change it to style the first
li that is a direct child of
If you want to be more specific use: