Ben Paton Ben Paton - 1 year ago 91
CSS Question

style 2nd element on the page with same class

Hello is there a way with css to style the 2nd element on page with the same class slightly differently to the first.

For example I have two ul's on a page with a class of topbardropdownmenu. I want to give the 2nd ul a differen't background to the first. Is there a way to do this with out altering the html?

Answer Source

What holds the <ul> elements? I'll assume a <div id = "lists">

/* First element */
div > ul.topbardropdownmenu:first-child{


/* Rest of the elements */
div > ul.topbardropdownmenu{



div > ul.topbardropdownmenu:not(:first-child)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download