Friday, May 2, 2008

Centering problem in Interner Explorer

IE7 seems to be having problems centering text in the column if column width is defined in CSS.

Lets say following CSS is applied to a table column:
{ width: 50px; text-align:center; }

When table cell gets widened because content does not fit, IE would still center content based on initial value (50px, as specified in CSS).

In order to fix IE behavior, add col tags. These will somehow force IE to use correct width while centering
<table>
<colgroup>
<col width="1%" />
<col width="1%" />
</colgroup>
<tr>...

No comments: