I have another reason the answer is “NO!!!” … and also an exception to the rule.
Why No? Because your style you are adding (Paul’s first example is a classic example of this) MAY NOT BE APPROPRIATE FOR ALL YOUR MEDIA TARGETS.
You are using the media attribute, right? As a rule of thumb, sending ANY CSS to “ALL” is a bad idea and frankly, broken methodology. Since most of the inlined style people use doesn’t bother with @media (I’m not even certain it can), when it comes time to make handheld, “screen and max-width” or more importantly “print”… bad things tend to happen. Again as I’ve said a billion times, web design should NOT just be about “screen” at the same magical combination of resolution and dpi setting you happen to be using. People do occasionally print pages, use them on hand-helds or small screens, screen readers, and even braille.
It plays to the four core reasons to use CSS:
-
Different styles for each media type
-
Ability to have different skins without changing the markup
-
reduce the number of redundant declarations in the markup by using separation of presentation from content.
-
Leverage caching models, not only to reduce bandwidth across pages by sharing like elements, but also to speed up loading of subpages by PRE-CACHING VALUES… Something the people who split up their CSS into page specific files often miss; Unless your page consists of nothing but bounce visits, pre-caching sub-page appearance is often a really good idea. ESPECIALLY when it eliminates an extra handshake on said sub-pages.
It’s like image recombination – loading two images as a single file so when you do the action, there’s no ‘delay’ waiting for the hover state image to load; Go to a sub-page, it’s CSS has already been downloaded making that sub-page appear to load faster, at a minor penalty to firstload.
THOUGH there are always exceptions to the rule – the only reason I wouldn’t remove the STYLE attribute from my toolbox. Sometimes, and this is VERY rare, the style CAN be used to assist in conveying DATA/Content. Not too long ago, ok, maybe a while ago… 13 months ago… We had a discussion here about showing stars for ratings and lighting them up… The solution I came up with:
Index of /for_others/TimMousel
May be nested span hell (might be able to fix that with generated content?), but it also uses the style attribute to pass the actual value to the CSS. Doing it this way also means that it works CSS off and images off without interfering with the different media targets, which can take or leave it.
Like anything else, there are always exceptions.