To Use or Not to Use "!important" in CSS
James_F
Registered Users Posts: 65 Big grins
Curious minds (me) want to know. I saw this earlier today - See http://www.smugocity.com/FAQ/Important - this FAQ strongly advises against the use of "!important" in CSS coding. That said, I see it used a lot by many of you in various CSS coding suggestions.
I'm a CSS newbie (I plagiarize a lot of what you all suggest.) So, what's the right answer - use "!important" or not? I'm simply trying to avoid any SmugMug issues further down the road if "!important" does in fact causes problems or will cause problems later.
I'm a CSS newbie (I plagiarize a lot of what you all suggest.) So, what's the right answer - use "!important" or not? I'm simply trying to avoid any SmugMug issues further down the road if "!important" does in fact causes problems or will cause problems later.
0
Comments
Images in the Backcountry
My SmugMug Customizations | Adding CSS to Your Site | SEO for the Photographer | Locate Your Page/Widget Number | SmugMug Help Desk
I still have !important specified for one set of code on my site; that's the only place where adding .sm-user-ui to the code didn't have the desired effect.
--- Denise
Musings & ramblings at https://denisegoldberg.blogspot.com
Former SmugMug Product Team
aaron AT aaronmphotography DOT com
Website: http://www.aaronmphotography.com
My SmugMug CSS Customizations website: http://www.aaronmphotography.com/Customizations
Thanks "leftquark": Your explanation helps a lot. The FAQ post that I had linked to in my opening post in this thread seems to suggest that !important could cause issues either now or in the future. You've clarified that issue. Having had the benefit of your explanation, I'd suggest that the FAQ post that I alluded to is misleading and needs at least some modification or clarification.
The only concern that I have with your explanation is that someone like myself does not know when we're trying to override a default and when !important is "important". There's no way of knowing what the default is. The process of CSS coding trial and error with SmugMug seems unnecessarily tedious. But I acknowledge that a lot of my SmugMug site tweaks and improvements are a result of using your creative CSS modifications. And, Aaron, I thank you a lot for that. Now, if someone can please teach me how to get the images captions closer to the bottom of my images, I'll be a happy Smugger.
Prescott, AZ
http://jamesfarrell.smugmug.com
not work I add the !important. If neither works I have to re-figure the class names.
My Website index | My Blog
Typically the use of !important on a website isn't needed because you, the web designer, are writing the CSS code. Rather than use "!important" you should just go back and get rid of the old code that you're trying to overwrite. In the case of customizations for SmugMug, though, things are a little different. You're overwriting SmugMug's code with your own ...
The use of !important, from what I've read, is actually a perfectly used here -- to create user controlled styles. It lets a user override a websites CSS for their own purposes. That's what you're doing when you customize you're site. In my experience, having a user customize CSS and use !important has not been to any detriment.
You brought up another point -- Smugocity hasn't been updated in quite some time. I've removed it from the stickies in this Forum and suggest people continue to post here with questions or check out Sherlock Photography or my own customization sites
Former SmugMug Product Team
aaron AT aaronmphotography DOT com
Website: http://www.aaronmphotography.com
My SmugMug CSS Customizations website: http://www.aaronmphotography.com/Customizations
Prescott, AZ
http://jamesfarrell.smugmug.com
Thanks for being so easy to work with James... and so understanding!
I'm going to do my best to post any updates to the "Product News" forum on here. If we release something that might break peoples CSS customizations I'll do my best to let you all know!
Former SmugMug Product Team
aaron AT aaronmphotography DOT com
Website: http://www.aaronmphotography.com
My SmugMug CSS Customizations website: http://www.aaronmphotography.com/Customizations