RE: [CSS3-values and units] attr() function questions

No expert on this feature either but this is how I understand it.

> - The spec says: "The third argument (which is optional) is a CSS
> value which must be valid where the attr() expression is placed."
> I assume "where the expression is placed" means "must be valid at the
> time of parsing"?

>From the subsequent statement, I think the answer is yes: 

	If it is not valid, then the whole attr() expression is invalid.

So this is intended to mean "The third argument (which is optional) must be a valid CSS vale for the property attr() evaluates into" i.e. :

	width:attr(length,em,blue);

...would be ignored just as 

	width:blue;

...would be.

Likewise, the type specified in the second argument may invalidate the expression if it does not match the property context it runs into.

The one thing that may need clarification is what does it mean for the attr() expression to be invalid i.e. is the attr() expression dropped or the whole statement ? 

> - Spec: "Note that the default value need not be of the type given.
> For instance, if the type required of the attribute by the author is
> 'px', the default could still be '5em'."
> Should this be allowed for string versus uri values for e.g. the
> content property, too? That is, should e.g. attr(href,url,"No Image")
> be valid? (in my current implementation I did not allow this).

Per above, the property context the function evaluates into is what matters. 
So your example would be a valid expression for a property that accepted both URL and string values i.e. what should make it invalid is the property accepting only URLs, not the type specified in the second argument.

> - I assume that the default is NOT used if an URI given by an
> attribute is valid but can not be resolved?

That is not what I would expect. The fallback value is to be used if the specified attribute is missing 
or its value cannot be used for the reasons specified i.e. 

	background-image:url('/this_will_fail');

...is equivalent to the following when the href attribute is missing:

	background-image:attr(href,url,url('/this_will_fail'));

> - Is an empty URI valid? That is, is a default with an empty URI
> valid? Or would this make the whole declaration invalid?
I think it's grammatically valid.

Received on Thursday, 16 April 2009 17:50:01 UTC