I have seen people set an element’s style to:
element{
position:absolute;
left:-10000px;
}
rather than setting:
element{
display:none;
}
Does the first method have better browser support, or why do they do it that way?
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.
An element whose display style property is
nonecannot be measured. Properties like offsetWidth and offsetHeight will always return0in that case.On the other hand, an element that’s visible but displaced outside the document area can be measured. So, if you want to hide an element but still be able to determine its width and height, the first solution is the way to go.