Results 1 to 5 of 5

Thread: How to make a table show up only on IE?

  1. #1
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to make a table show up only on IE?

    Hi guys. New to these forums, need some help.

    I'm planning to insert some content in a table, some of which shows up only on IE. I am hoping there is some code I can use to make the whole table show up only on IE, because the rest of the content in this table doesn't make sense without the IE-only bits.

    Would appreciate it if anyone could advise on such a code.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Use an "important" rule.
    It works like this:
    HTML Code:
    <style type="text/css">
    @media all {
    .ieonly {
    visibility: hidden !important;
    visibility: visible;
    }
    }
    </style>
    IE doesn't understand the !important rule, so the first rule to hide the table is overridden by the second, which shows the table. In other browsers that understand !important, the !important will prevent the first rule from being overridden, so the table remains hidden. Ugly hack, but it works.

    Another way of doing this does the opposite: using an IE-only feature, "conditional comments." This is a special syntax developed by Microsoft specifically for hiding/showing content to/from IE.
    HTML Code:
    <!--[if IE]>
    <table>
    This is technically a comment,
    so most browsers will ignore it,
    but because of the "if," IE will
    render it anyway.
    </table>
    <![endif]-->
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'd go with conditional comments. Hiding with style sheets will only work if that style sheet rule is applied, and this isn't a future-proof method: when Microsoft eventually fixes their CSS support (which they will to some extent in IE7), the content will be hidden from IE as well.

    Mike

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Of course, the best thing to do is make the whole table work on other browsers as well.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you Twey and mwinter. Went with conditional comments and it works beautifully

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •