Re: attr(x, y)

On Sat, 13 Sep 2003, Sigurd Lerstad wrote:

> 
> Hello,
> 
> Where is the syntax of property value attr(x,y) described?
> 
> In CSS2, there's only attr(x), so attr(x,y) must be new to CSS3? But I can't
> find where it's described.

It is currently meant to go into the Values & Units module.

The idea is to generalize attr() a bit. The optional second argument can
be a type ('string', 'color', 'url', 'length'...) to allow attr() to be
used on properties that allow other things than strings. E.g., the type
'url' would indicate that the attribute value is a URL reference relative
to the document, because simply taking the attribute as a literal string
would give the wrong URL. The default type is 'string'.

There is also an optional third argument, which acts as the default if the
attribute is not present in the document or cannot be converted. If the
third argument is omitted, the default depends on the type, the default 
for 'string', e.g., is the empty string.

The proposal will have many details about the types and defaults. But the
interesting question is how well it will work with existing and expected
XML-based formats. It will allow 'BODY {background: attr(BGCOLOR,color) }'
and 'OL { counter-reset: list-item attr(START,integer) }', but it won't
help setting borders on the descendants of "<TABLE BORDER=2>". That
particular example is probably not a good counterargument, since we have
been doing fine without the BORDER attribute anyway, but there may be more
compelling examples outside of HTML.



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos/                              W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Sunday, 14 September 2003 09:05:29 UTC