sIFR 3: Experiments: Tuning: Deducing line-height in IE

Internet Explorer's equivalent of document.defaultView.getComputedStyle () unfortunately returns it's values with their original unit, as opposed to the MOSe browsers which return it in pixels. This means we have to find a different way of finding the line height. A solution lies in getClientRects (), which not only returns the exact number of lines but also the position of each individual line. Unfortunately in IE a line includes the padding of the element, so a workaround is needed. Temporarily setting the content of the element to exactly three lines and then calculating the height of the second line gets us the line height without any padding.

Test subjects

This text normally fits on one line

This text normally fits on
two lines

This text normally fits on
two lines, with extra padding of two lines worth

This text normally fits on
two lines, with extra padding of four lines worth

This text normally
fits on
three lines

Output