The poor old
!important statement receives a lot of flak in the CSS community, and with good reason. It’s unnecessary, creates a maintenance nightmare, and makes a hollow mockery of the cascade. I haven’t thought about using
!important in years, until I discovered one very good use for it: print style sheets.
opacity of the images, so only one is revealed at a time. When we go to print the gallery page, although we want a single column of images, what we end up printing is only a single image. That’s because you’re unable to specify a target media type for CSS declared in an element’s
style attribute; you cannot say that all styles declared in the
style attribute are for
So what you need is a way of specifying print styles that can override the inline styles. There’s only one way to do that:
!important. In your print style sheet, reset the image elements’
opacity, and add
position: static !important;
opacity: 1 !important;
That’s it really; I found a legitimate use for
!important and wanted to share it.