|  | Posted by Jukka K. Korpela on 02/27/06 00:07 
Harlan Messinger <hmessinger.removethis@comcast.net> wrote:
 > But the user may have a stylesheet with
 >
 >      STRONG { background-color: red ! important; }
 >
 > though I doubt it.
 
 Well, it's a poorly written style sheet since it does not specify
 color. We cannot protect against such style sheets. We can and should
 protect against clashes with technically well-designed user style
 sheets, such as
 
 STRONG { background-color: red ! important; color: white ! important; }
 
 (which would not result in a problem in this case) _or_ the same
 without the !important specifiers.
 
 > However, in your scenario, you could use the
 > selector
 >
 >      div#content STRONG
 >
 > instead. The user's stylesheet is highly unlikely to have anything
 > applicable that's of higher specificity than that.
 
 Specificity isn't all. A user style sheet can trump all rules in an
 author style sheet, even using the least specific selector *:
 
 * { color: white !important; background: black !important; }
 
 In this case, problems would arise if the user style sheet had
 
 div { color: white !important; background: red !important; }
 
 But things really get _more difficult_ when people try to avoid
 declaring colors and backgrounds together. I can understand some
 reasons to such reluctance, but there's really no other way to write
 robust style sheets.
 
 --
 Yucca, http://www.cs.tut.fi/~jkorpela/
 Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
  Navigation: [Reply to this message] |