32766

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Update December 2011: This bug is fixed in Opera 11.60

This is a bit of an interesting number. Google turns up a number of bug-related threads. The reason it came up for me, is that I get a lot of emails like this:

The AnythingSlider doesn’t work in Opera!!!

They were right… but it seemed to be a fairly new issue and I never could figure out why. It turns out it all comes back to 32766.

I used to get emails from people who were using the AnythingSlider and added like 80 slides to it and it didn’t work anymore. The reason was always that the inside <ul> element that wrapped all the slides was too narrow to fit their 80 slides. It was set at a fixed width of 9999px. The right answer would have been to make the wrapper the width of one slide multiplied by the number of them (via the JavaScript). But just in being lazy, I just added another “9” to the width making the wrapper 99999px. This was the change the borked Opera.

Apparently, Opera can’t handle widths greater than 32766px. There is a thread in Opera’s forums which means I’m not alone here.

Reader Erdei Csaba clued me in:

32766px … is the highest signed 16-bit number (32767) – 1.

Opera must store these values as signed 16-bit numbers. And apparently higher positive values (> 32767) are processed as negative values. The CSS1 spec explicitly forbade negative width values, but the newer specs don’t really say anything about it. They probably assume they didn’t have to say anything, because it’s obviously pretty ridiculous to have a negative width.

Long story short: the maximum width of an element in Opera is 32766px, and that probably should be fixed.