Skip to content Skip to sidebar Skip to footer

How To Stop Nested List From Inheriting Style From Parent List?

I want to add a nested list but I am having a problem with it inheriting from the parent list. I've followed this question and this question but they haven't helped. How could I ge

Solution 1:

don't use background-color in li use it in anchor

.innerLeftullia{
    background: red;
    display:block;
}

this will solve your issue

updated jsFiddle file

Solution 2:

The following rule tells the browser to render any list element inside innerLeft with a red background:

.innerLeftulli {
    background: red;
    padding:0px;
    margin:0px010px0;
    height:18px;
}

Use specificity to target the first ul:

ulli {
  background-color: #fff;
}
.innerLeft > ulli {
    background: red;
    ...
}

By using the > selector, you are telling the browser to select the child of .innerLeft, or direct descendant.

Post a Comment for "How To Stop Nested List From Inheriting Style From Parent List?"