What are the maximum and minimum values, in pixels, for the CSS background-position property?
More precisely, if we use
background-position: xpos ypos;
where xpos and ypos are pixels, what is the allowed range for xpos and ypos?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The values for
background-positionwhen specified with pixels as unit is defined as<length>, which is a real number.The specification for a real number doesn’t mention any limit for the number itself.
The actual values that are usable would be limited by the implementation in the browser. There is a limit to the size of the document based on the size of the variables that are used to keep track of it. Older browsers could have a limit like 32767 pixels (16 bits, signed), but nowadays we see larger web pages, and the limit is likely to be more something like 2147483647 pixels (32 bits, signed).
As browsers are implemented differently, you should keep the values to a reasonable range just to be safe.