Solution to “display:table-row” causing pain and suffering with IE

I recent­ly came up against a sit­u­a­tion where I want­ed to add rows to a table via javascript.

Not a prob­lem with jQuery, EXCEPT that my table rows were being added with ‘style=“display:block“ ‘.

What’s wrong with that, you ask? Well, in Fire­fox the row was being append­ed to the table but it looked all scrunched into the first cell like so:


OK, fine. Let’s give it a dis­play prop­er­ty of “table-row.” That should work, right? Yes, it works here but not in IE. IE hates this, in fact. IE wants to get a dis­play of “block.”

The solu­tion turns out to be to set the dis­play val­ue to an emp­ty string. Then, each brows­er will give the row its default val­ue and every­one is hap­py.


This site uses Akismet to reduce spam. Learn how your comment data is processed.