W3C home > Mailing lists > Public > www-style@w3.org > April 2005

Re: WHATWG Attribute puzzle

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Tue, 05 Apr 2005 15:05:05 +1000
Message-ID: <42521C80.9030203@lachy.id.au>
To: Matthew Raymond <mattraymond@earthlink.net>
CC: W3C CSS <www-style@w3.org>

Matthew Raymond wrote:
> 
>    Say you're using one of those new WHATWG values for the |type| 
> attribute of <input>:
> 
> | <input type="date" name="date1">
> 
>    How do you style the above markup so that user agents that support 
> the "date" type will user one presentation, but legacy user agents will 
> use another presentation?

This is simply not possible to do with any useful method, simply because 
there is no way to select an element based on the way the user agent 
processes it, only based on its markup.

> In other words, how would I put a green border around the date control I'd
> see in a Web Forms 2.0 compliant browser, but show a red border around the
> text box created in browsers that don't support it?
> 
>    I'm pretty sure the following does *not* work:
> 
> | input { border-width: 2px; border-color: blue; }
> | input[type=text] { border-color: red; }
> | input[type=date] { border-color: green; }

No, it won't work, because UAs are still going to have type="datetime" 
within the DOM, even though they are treating it as type="text".

As a work around, you could possibly make use of a selector that is 
commonly supported by Web Forms 2 UAs, but not by non-Web Forms 2 UAs. 
Basically, you'll have to make use of a CSS filter of some kind. 
However, this would fail for any UA that implements the selector used, 
but not web forms or vice versa.

The only other possible solution could involve a script of some kind 
that tests for WF2 support, but I don't believe there can ever be good 
CSS only solution.

-- 
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/     Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Received on Tuesday, 5 April 2005 05:05:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:36 GMT