I've been using an ID plus descendants style rule to give all descendants of a div no padding and no margin. But I noticed that it's more specific than the styles in ID selector.
I have multiple divs. Is there a way to make it less specific?
In the example below the padding and border is not applied because the ID+* is more specific:
#list1item1 {
padding-left: 10px;
outline: 1px dashed green;
}
#list2item1 {
padding-left: 20px;
outline: 1px dashed blue;
}
#GroceryList1 {
left: 40px;
top: 20px;
position: absolute;
}
#GroceryList2 {
left: 200px;
top: 20px;
position: absolute;
}
#GroceryList1 * {
margin: 0;
padding: 0;
outline: none;
}
#GroceryList2 * {
margin: 0;
padding: 0;
outline: none;
}
<div id="GroceryList1">
<ol>
<li id="list1item1">Bread
<li>Stick of Butter
<li>Gallon of milk
</ol>
</div>
<div id="GroceryList2">
<ol>
<li id="list2item1">Bread
<li>Stick of Butter
<li>Gallon of milk
</ol>
</div>
Without switching to classes is there a way to select all descendants of a div where a regular ID selector is more specific?