If I do this:
*{padding:0}
div#myDiv{padding:10px;}
Will that behave like any normal styling in CSS with the last style applied overriding others? i.e. The element with the myDiv ID will have 10px padding? Or do I have to specify !important?
Will this work on all popular browsers?
Thank you!
Yes: the
<div id="myDiv">element will have a10pxpadding, and this works on nearly every browser. Cascading means more specific selectors will override more general selectors.The only time you’d really need to use
!importantis when you have a more general style that you want to take precedence over a more specific style, or when you have two different styles for the same selector, like to take advantage of quirks in older browsers that don’t support!important.