Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How large can CSS values be?

I have a problem with CSS values larger than 2¹⁵ in Opera, such as width:32999px.
I want to know how large the values can be in CSS or HTML, depending on the browser.

like image 242
Dariush Jafari Avatar asked Mar 26 '26 07:03

Dariush Jafari


2 Answers

Opera has a bug that limits CSS values to 32766. They use signed 16 bit integers which causes the limit. It is a known problem and hopefully they will fix it soon. Other browsers don't have the same limit and I couldn't find much on other browsers' limits, but they will be at least 65535, possibly more. There is a thread in the Opera forum at http://dev.opera.com/forums/topic/242545?t=1269270866&page=1

like image 51
G-Nugget Avatar answered Mar 28 '26 19:03

G-Nugget


I'm guessing you are doing this as a "hack" in order to hide something. So there are probably better ways to achieve what you want to achieve.

If you want something to be gone from the page both visually and semantically, use display: none. If you want something to be gone from the page visually but still take up space and still be there semantically (visible to non-visual user agents), use visibility: hidden. If you want something to be gone from the page visually but still be there semantically, but not to take up any space, you could try adding a position:absolute or a height: 0 or something else like that in addition to the visibility: hidden.

To answer your original question, the limit you're hitting is probably 2^15 - 1, or 32767 (and if you take rounding into account, take another few off that). This is the highest allowed number for a 16-bit signed integer. However, there is no standard that says this should be a limit; you're probably just hitting a browser-specific limitation.

like image 41
thomasrutter Avatar answered Mar 28 '26 20:03

thomasrutter