[css3-values] Suggestion: Allowing attr() in calc()

  I would be quite surprised if this hasn't been suggested before, but I searched the archives quite extensively with no avail.

As things currently stand, number and length values from attr() are not allowed inside calc(), since <atomic-length> is defined as only <number><length-unit> and nothing else [http://www.w3.org/TR/css3-values/#calc]. It's not as explicitly disallowed in the dev version of the spec, but it still doesn't seem to be permitted.

Is this a deliberate omission?

I think attr() values in combination with calc() could be enormously useful, at least for attr() expressions that return the types integer, number, length, angle, time, frequency and the various units. For the other attr() types it could be treated the same as if an invalid value was directly put into calc().

Attributes would contain the actual, semantic data and then calc() could be used to utilize this data for presentation purposes, operating on them and performing any necessary calculations. If attr() cannot be combined with calc(), I'm afraid authors may start contaminating their markup with attributes that only hold presentational information. A good example for this is CSS bar charts (I actually stumbled upon this shortcoming of CSS3 when trying to create a CSS bar chart with "clean" markup)

-- 
Lea Verou
Blog: leaverou.me <http://leaverou.me>
Twitter: http://twitter.com/LeaVerou
LinkedIn: http://gr.linkedin.com/in/leaverou

Received on Wednesday, 1 September 2010 07:57:36 UTC