IE CSS bug: table border showing div with visibility: hidden, position: absolute

Posted by Alessandro Vernet on Stack Overflow See other posts from Stack Overflow or by Alessandro Vernet
Published on 2009-01-10T03:08:26Z Indexed on 2010/05/15 21:34 UTC
Read the original article Hit count: 267

Filed under:
|
|

The issue

I have a <div> on a page which is initially hidden with a visibility: hidden; position: absolute. The issue is that if a <div> hidden this way contains a table which uses border-collapse: collapse and has a border set on it cells, that border still shows "through" the hidden <div> on IE.

Try this for yourself by running the code below on IE6 or IE7. You should get a white page, but instead you will see:

alt text

Possible workaround

Since this is happening on IE and not on other browsers, I assume that this is an IE bug. One workaround is to add the following code which will override the border:

.hide table tr td {
    border: none;
}

I am wondering:

  • Is this a known IE bug?
  • Is there a more elegant solution/workaround?

The code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <style type="text/css">

            /* Style for tables */
            .table tr td {
                border: 1px solid gray;
            }
            .table {
                border-collapse: collapse;
            }

            /* Class used to hide a section */
            .hide {
                visibility: hidden;
                position: absolute;
            }

        </style>
    </head>
    <body>
        <div class="hide">
            <table class="table">
                <tr>
                    <td>Gaga</td>
                </tr>
            </table>
        </div>
    </body>
</html>

© Stack Overflow or respective owner

Related posts about internet-explorer

Related posts about bugs