Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7739271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:28:53+00:00 2026-06-01T08:28:53+00:00

I have an HTML table containing a few rows (this is built dynamically). All

  • 0

I have an HTML table containing a few rows (this is built dynamically). All <tr>s have one <td> inside.

If one <td> doesn’t have HTML content inside, I would like it to be invisible.

How can this be done? (Not that the HTML inside is rendered dynamically and I do not want to use display:none or any other property on the <td> or <tr>).

Code sample:

<html>
    <body bgcolor="#E6E6FA">
        <table cellSpacing="0" cellPadding="0">
            <tr>
                <td>one cell</td>
            </tr>
            <tr>
                <td bgcolor="#FF0000"></td>
            </tr>
            <tr>
                <td>two cell</td>
            </tr>
        </table>
    </body>
</html>

In Firefox the empty TD is invisible. However, in IE the TD takes up 1 pixel in height:

enter image description here

Looking with DOM Inspector I see that it takes 1 pixel:

enter image description here

How can I set the TD not to be visible? Any scripts I can execute inside the TD?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:28:55+00:00Added an answer on June 1, 2026 at 8:28 am

    You can use the CSS pseudo selector :empty:

    #myDynamicTable td:empty
    {
      display: none;
    }
    

    jsFiddle example: http://jsfiddle.net/vKEBY/6/

    And if you want to support IE<9:

    var ieVer = getInternetExplorerVersion();
    if (ieVer != -1 && ieVer < 9.0) {
        // for IE<9 support
        var dynamicTable = document.getElementById("myDynamicTable");
        var TDs = dynamicTable.getElementsByTagName("td");
    
        for (var i = 0; i < TDs.length; i++) {
            if (TDs[i].innerHTML == "") {
                TDs[i].style.display = "none";
            }
        }
    }
    
    /**
      * All credits to Microsoft
      * http://msdn.microsoft.com/en-us/library/ms537509(v=vs.85).aspx#ParsingUA
      */
    function getInternetExplorerVersion()
    // Returns the version of Internet Explorer or a -1
    // (indicating the use of another browser).
    {
        var rv = -1; // Return value assumes failure.
        if (navigator.appName == 'Microsoft Internet Explorer') {
            var ua = navigator.userAgent;
            var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
            if (re.exec(ua) != null) rv = parseFloat(RegExp.$1);
        }
        return rv;
    }​
    

    jsFiddle example: http://jsfiddle.net/vKEBY/6/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an aspx page with 1 table containing 2 rows: <!DOCTYPE html PUBLIC
I have a Table containing some information that I need. All these rows also
I have a jQuery function to dynamically add rows containing input fields, this exists
I have an html table containing values that are being generated from javascript. How
I have an html table which i bind data dynamically on the server side
I have an HTML table that looks like this: ------------------------------------------------- |Column 1 |Column 2
I have a HTML table like this: <table border=1> <tbody> <tr> <td><a href=# class=delete>DELETE
I have a HTML table like this: <table border=1> <tbody> <tr> <td><a href=# class=delete>DELETE
I have an HTML table with one column being email addresses; spambot issues aside,
I have a fairly complicated html table containing lots of PHP, CSS etc., and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.