Not !Important

I’m currently working on a SharePoint project that’s going to involve a number of fairly kludgy bits, mostly because… SharePoint. I think I may be able to get a few mildly amusing blog posts out of this project. Today’s one is about the !important directive in CSS.

This article titled “When Using !important is The Right Choice” should probably be one word long: never. Understanding specificity in CSS is important, and there are occasions where it’s appropriate to use !important, but only a few. Using it in a site-wide template for a SharePoint site is not one of them, under most circumstances. I had to write a little JavaScript (using jQuery) to hide part of a SharePoint page, and that task was made more difficult than it needed to be due to overuse of !important in the site template.

I’m the first to admit that I don’t know nearly as much about CSS as I should, but I know enough to know when I’m looking at a careful design, and when I’m looking at “let’s just try random stuff until this looks right.” Heck, I probably shouldn’t criticize; the base CSS on a SharePoint site is probably already pretty bad, so someone designing a custom template likely has an uphill battle getting his or her own CSS to work well within the framework provided by Microsoft. SharePoint is old enough that it’s supporting a lot of dead weight from old versions, most of which probably can’t be trashed without breaking too much stuff.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.