I have an area that is identified by a #id and there is a CSS like:
#id ul li {
margin:0;
}
can I, for a specific UL in that area, override the margin-setting? I understand that #id creates very high priority in evaluating the formatting.
I have tried:
.myclass ul li {
margin-left: 20px;
}
and
#id ul.myclass {
as well as
#id li.myclass {
Is it even possible?
I agree with SWilk, avoid
!importantif possible (and it is possible here). Some other solutions that SWilk did not offer is:or…
The key is increasing the specificity of the selector, which the above, and SWilk’s solutions do. The reason your original solutions did not work is that you did not include the other tag (
ulorli) nor the#idwith your addition of the.myclass.Added after your comment that showed structure:
If your html is this (as you stated in your comment):
And your current css is (as stated in another comment):
The reason you are not seeing any change is because three of your selector paths do not exist in your html structure, and the one that wins by specificity is the very first group. You need:
To override the
#ja-col2 ul li.