#iddiv span {
display: inline-block;
width: 190px;
}
.myclass {
width:10px;
}
Then I have
<
Remember to use the keyword, !important, which functions to overwrite parent rules.
Also you can define your "myclass" in the following way:
#iddiv span.myclass {
width:10px;
}
Because id+selector (#iddiv span) is more specific than a class. Either
#iddiv span.myclass
or
#iddiv .myclass
should work for this case.
Learn more about CSS specificity here or by Googling it.
CSS applies styles according to the specificity of the selectors
#iddiv span
is more specific than myclass
. Changing it to #iddiv .myclass
should fix the issue for you.
Here's an article that goes more in depth about this : http://htmldog.com/guides/cssadvanced/specificity/
First of all, I'd suggest you properly target your selectors, as others are suggesting.
But when all else fails, you can use !important.
It's not working because the first style is more specific.
To fix it, make sure you target the second span
more directly, like this
#iddiv span.myclass
http://jsfiddle.net/jasongennaro/5fe9A/
You could always use the !important
flag to override:
.myclass {
width: 10px !important;
}