2

Possible Duplicate:
What bug does zoom:1; fix in CSS?

If I am not incorrect, the default value for the CSS property zoom is 1. And in about the last 6 or 7 online code files regarding CSS, I have seen somewhere in the code this mysterious line of code:

zoom: 1;

Is there a semantic meaning to this piece of markup? Is there a reason why they include it?

Community
  • 1
  • 1
Lucas
  • 16,930
  • 31
  • 110
  • 182

1 Answers1

7

Using this rule is the fastest (and - usually - the cleanest) way to activate hasLayout property for an HTML element. This, in turn, affects (usually in positive way) its rendering in older versions of Internet Explorer:

In Internet Explorer, an element is either responsible for sizing and arranging its own contents, or relies on a parent element to size and arrange its contents.

In order to accommodate these two different concepts, the rendering engine makes use of a property called hasLayout that can have the values true or false for the element concerned. We say an element gains a layout or has a layout when the hasLayout property has the value true.1

When an element has a layout, it is responsible for sizing and positioning itself and possibly any descendant elements. In simple terms, this means that the element takes more care of itself and its contents, instead of relying on an ancestor element to do all the work. Therefore, some elements will have a layout by default, though the majority do not.

I'd recommend reading this article as well (the quote is from there actually).

thirtydot
  • 224,678
  • 48
  • 389
  • 349
raina77ow
  • 103,633
  • 15
  • 192
  • 229