Forum Bugs

Minor bug: attr(attrib-name, %) doesn't work

kmmv
Just a minor bug: attr() according to the CSS 2.1/3[1] spec should accept percentages as a <type>.

table[width] {
    width: attr(width, %);
}


doesn't work with

<table>


as expected. Unfortunately, I can't find a validator that appropriately validates it, either. Note that doing width: attr(width) and using width="80%" works as expected.

[1] http://www.w3.org/TR/css3-values/#attribute
mikeday
We actually support this with a "percent" keyword instead of a literal % character. There are rules in the default XHTML style sheet to handle the HTML width and height attributes:
*[width] { width: attr(width, px, attr(width, percent)) }
*[height] { height: attr(height, px, attr(height, percent)) }

This will try to parse the attribute as a number that will be interpreted as a pixel length, and if that fails it will try to parse the attribute as a percentage value, and if that fails it will fallback to the default value for the properties (auto).