Quantization error in Opera for CSS margin, padding, border values

Opera 7–9.2 shows a rough “quantization” error when a margin, padding or border has a value greater than 20.47 and it is expressed in em units, or ex, %, cm, in (with other units, like px, the problem would not be visible, even if present.)

In the above conditions the decimals are simply ignored. For example, all margins of 21em, 21.1em, … up to 21.9em are rendered exactly the same. This is not a simple rounding error.

Only margins, paddings and borders seem affected, not other properties (like width, left, top, …) The problem is not present below the threshold value of 20.47. No other browser displays a similar behaviour (not even Opera 6.)

The problem has been mostly fixed in Opera 9.5. Padding and margins expressed in em do not show it anymore. Other combinations still had problems, for example em borders were still wrong for values greater than 20.47 in Opera 9.5; this is almost fixed in Opera 10.5. When using percentage widths Opera still ignores all decimal figures (i.e.: width: x.y% is always equal to width: x%). There is also a limitation in nth-child.

Examples

In the below test case there is a series of green bars having an increasing margin-left with a 0.01em step. Check what happens (in Op7–9.2) when the value exceeds 20.47em: the margins do not increase regularly anymore, but in a “stepped” way.

Other em margin tests:

Other properties tests in em:

Percentage tests:

Some tests with other units:

19.0
19.1
19.2
19.3
19.4
19.5
19.6
19.7
19.8
19.9
20.0
20.1
20.2
20.3
20.4
20.5
20.6
20.7
20.8
20.9
21.0
21.1
21.2
21.3
21.4
21.5
21.6
21.7
21.8
21.9
22.0
22.1
22.2
22.3
22.4
22.5
22.6
22.7
22.8
22.9

CSS tests home