Ali Ali - 1 month ago 11
CSS Question

Style all Bootstrap 3 navbar links except those under ul

Style all anchors/links:

.navbar li a {
color: blue !important;
}


Style anchors/links under ul:

.navbar ul li a {
color: blue !important;
}


I would like to achieve 2 different scenarios:


  • Style all links, except those under ul

  • Style all links, except those under class .dropdown-menu (ul)



JsFiddle

Answer

Do you mean all nested links should not be colored blue? if so change the css as below.

.navbar li a {
  color: blue !important;
}

/* Link under ul only */
.navbar ul.dropdown-menu li a {
  color:initial !important;
}