-1

HOw to style link with class selected under this html structure

<li class="submenu_items" style="display: list-item;">
        <ul>
            <li>
                <a class="selected" href="/page">Page</a>
            </li>
        </ul>
    </li>
user1765862
  • 13,635
  • 28
  • 115
  • 220

3 Answers3

1

This should do it for you:

.submenu_items ul li a.selected{
     /* your CSS properties here */
}

You can also use the > operator to denote a direct descendant.

There are a number of variations in how you can target the .selected link, I'd also reccommend you have a look at the MDN article on CSS specificity

Community
  • 1
  • 1
SW4
  • 69,876
  • 20
  • 132
  • 137
1

Use the below to style selected

.submenu_items ul li > a.selected{/* your code goes here. */}

Hope this helps.

Nitesh
  • 15,425
  • 4
  • 48
  • 60
1

To over-ride parent styles (in this case 'submenu_items') you just need to make your CSS targeting more specific. For example:

.submenu_items ul li a.selected{
/* Add your CSS */
}
d.abyss
  • 204
  • 1
  • 4
  • 26