In production level code, !important rule should only be used for testing purposes. The reason(s) are that this rule overrides all other rules set which affects the cascade and makes maintenance a nightmare when you are trying to find or change a particular rule set.
It's always advisable to use it with caution and very sparingly if not at all. Sent from my iPad On Mar 3, 2011, at 9:48 AM, Nikki Goelz <[email protected]> wrote: > The !important rule is a way to make CSS cascade but also let the rules you > feel are most critical be applied, it flags the element as an important > declaration, rather than a normal declaration. An important declaration holds > more weight than a normal declaration as your browser renders code. > > !important; can be added to elements to force cross-browser consistency. So > in the case of your sample code I believe the coder is trying to ensure a > consistent font size and padding throughout the site and across multiple > browsers. > > As Justin recommends you can remove those bits and see what on the site > changes to better understand how it's effect the site as a whole. > > Hope that helps! > > On Wed, Mar 2, 2011 at 9:41 PM, Justin Hall <[email protected]> wrote: > > > > On Mar 2, 2011, at 8:45 PM, Keith Purtell wrote: > > I asked an excellent Web designer to critique my site, and he created a > whole new style sheet that made it look better. The problem was, there were > some lines of code he included that I didn't understand. Obviously I need to > know what every line of my CSS does, so here are some examples of what he > wrote. As for why I don't ask him to explain it, he's been very impatient > with me when I asked that type of question. > > The first example is figuring out the logic of when to use !important ... > ul#navlist li.inCat em, ul#navlist li em, ul#navlist li.inCat strong { > display: block; > font-style: normal; > font-weight: 700 !important; > color: #675645; /* was 000 */ > padding: 6px 0 6px 30px !important; > } > > Nothing really too complicated about that CSS. !important is often used for > diagnostic reasons or to override previous styles > The latter is likely what he's using it for. > > > > Second example looks like a hack for IE6 but not sure what it's trying to > accomplish with that 1% ... > * html ul#navlist li a, * html ul#navlist li.inCat em, * html ul#navlist > li.inCat strong { > height: 1%; > } > > > Can't really be sure without looking, but my guess is he might have been > trying to manage a layout bug or 2 between browsers. Best bet, take it out > and see what happens. > > -- > -- > You received this because you are subscribed to the "Design the Web with CSS" > at Google groups. > To post: [email protected] > To unsubscribe: [email protected] > > -- > -- > You received this because you are subscribed to the "Design the Web with CSS" > at Google groups. > To post: [email protected] > To unsubscribe: [email protected] -- -- You received this because you are subscribed to the "Design the Web with CSS" at Google groups. To post: [email protected] To unsubscribe: [email protected]
