www.webdeveloper.com
Results 1 to 3 of 3

Thread: Table with a div inside of it

Hybrid View

  1. #1
    Join Date
    May 2009
    Posts
    5

    Table with a div inside of it

    Hi,

    I'm trying to code two table a parent table with a child table. I want the child table to have a div wrapped around it. However the display none is not working on it. Both table are visible at time of rendering the web page. Any help on this would be greatly appreciated.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
        <title></title>
    </head>
    <body>
    <TABLE BORDER='0'><tr>
    <td><A onClick='toggle()'><IMG src=./image/closed.gif height='14px' width='12px' />123&nbsp;&nbsp;&nbsp;</A></td>
    <td>AA</td><td>01</td>
    <DIV style='display: none;' id ='test'>
    <TABLE BORDER='0'> <th><tr style='font-weight:bold'>
    <td>Description</td>
    <td>NS</td></tr>
    <th><tr><td>product</td>
    <td>54321</td></tr>
    </TABLE></div>
    </tr></TABLE>
    </body>
    </html>

  2. #2
    Join Date
    Apr 2010
    Location
    Cocoa Beach, FL
    Posts
    41

    Possible Solution To Web CSS Issue

    When doing web applications, When you are using divs within a table they should always be enclosed with a table cell <td></td>. If the div is outside of those within the table, the display:none; CSS will not work. I tried it on my own webserver and found that to be the case. Here is your HTML rewritten to correct the problem:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    </head>
    <body>
    <TABLE BORDER='0'><tr>
    <td><A onClick='toggle()'><IMG src=./image/closed.gif height='14px' width='12px' />123&nbsp;&nbsp;&nbsp;</A></td>
    <td>AA</td><td>01</td>

    <td>
    <DIV style='display: none;' id ='test'>
    <TABLE BORDER='0'> <th><tr style='font-weight:bold'>
    <td>Description</td>
    <td>NS</td></tr>
    <th><tr><td>product</td>
    <td>54321</td></tr>
    </TABLE>
    </div>
    </td>

    </tr></TABLE>
    </body>
    </html>

    Michael G. Workman
    michael.g.workman@gmail.com

  3. #3
    Join Date
    Aug 2011
    Location
    Worthing, West Sussex
    Posts
    96
    Tables are terrible, do not use them.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles