[whatwg] [html5] Rendering of interactive content

Smylers Smylers at stripey.com
Wed Feb 11 07:13:53 PST 2009


Aryeh Gregor writes:

> On Wed, Feb 11, 2009 at 8:36 AM, Smylers <Smylers at stripey.com> wrote:
> 
> > That is precisely an instance of an author setting a background
> > colour without a foreground colour -- specifically the author set
> > the background colour used on links without setting the foreground
> > colour for links.
> >. . .
> > Browsers do of course (typically) set both together -- in that they
> > provide a default background colour, plus foreground colours for
> > visited links, unvisitied links, and non-link text.
> 
> I interpret "authors should always set background and foreground
> colors together" as "no single CSS rule should set 'background'
> without setting 'color' or vice versa".  I can't figure out exactly
> how you're interpreting it.

Ah, I see.  Thanks for explaining that.  I'm interpreting it as "for
each bit of text that you cause the background colour to be set for,
also specify its foreground colour (and _vice versa_)".

So it's reasonable for a browser to set a background colour on <body>
and know that other elements take their background from that.

> The point is that to ensure that the foreground and background don't
> conflict, you must always set foreground and background colors *in the
> same CSS rule*.  As long as all stylesheets observe this principle,
> there will never be a mismatch.

True, but that introduces other awkwardnesses.  Given that many pages
(or regions of pages) have a background colour shared across several
elements, it's tedious to have to specify it for each one -- and also
harder to change.

If the default browser style-sheet explicitly specified the background
colour for links (rather than letting the <body> background show
through) then authors would have to override all of them, instead of
just the <body> colour.  I expect that would break many existing
websites.

> Either the color and background are overridden both at once, or not at
> all, since the cascade works on a rule-by-rule basis, not
> property-by-property.

On that basis transparent backgrounds are useless, since you can never
be sure that somebody else won't change the background colour of the
parent element without ensuring none of its content's text colours
clash.

HTML elements nest.  People expect that setting a background on an
elment makes it appear behind all nested elments it contains.  Let's
work with that, not against it.

> The browser is the one that's failing to observe the principle in this
> case, and the author is observing it.  The author is *not* setting the
> background color for :link, nor the foreground color.

However she's including link elements inside a <body> for which she has
set a background colour.  Therefore, by my understanding, she's
specified a background colour without a foreground colour.

Your interpretation and my interpretation both 'work'.  However, mine's
less hassle to deal with (avoids proliferation of repetitive properties)
and compatible with the extant web.

> > If an author overrides one of those four then he generally needs to
> > override all of them (except in circumstances where he knows the
> > area in question won't have any links, or any-non links, or any
> > text).
> 
> So you're saying links are a special case for this principle?  Why?

Yes.  Because links typically have a different colour -- as defined in
the expected styling information given in HTML 5, and therefore authors
should expect it.

> UAs might just as reasonably change the colors of other elements as
> well.  It's only convention that says they only change the color of
> links.

Yes.  Conventions are good.

> But that exact same convention says that the color of links is blue.

Fair point.  But browsers have for a long time provided UI for users to
specify other link colours in way that they haven't, for exmaple, the
colour of headings or emphasized text.  I'm sure some users take
advantage of such UI (and wouldn't consider them to be user
style-sheets; somebody clicking on such UI possibly isn't even aware of
the concept of user style-sheets).

There are plausible reasons why a user would want to set non-default
colours, perhaps to make things easier to read.  And if he sets a
different text and background colour, he's likely to want to set
different link colours too, so that they still stand out.

Smylers



More information about the whatwg mailing list