Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display:none

Status
Not open for further replies.

ErinC

Programmer
Jun 29, 2001
3
US
This has been driving me nuts. Why doesn't this work?

<table>
<div style=&quot;display:none&quot;>
<tr><td>hi</td></tr>
</div>
<table>

Thanks,
Erin
 
You can not hide a whole block, only a particular element. It will work if you specify it in the cell itself such as:


<table>
<div>
<tr><td style=&quot;display:none&quot;>hi</td></tr>
</div>
<table>

If you want to not display the whole table or a particular row specify in the head of the page, the style atribute for the particular element such as:
Code:
<head>
<style>
table {display:none}
</style>
</head>

This will work for you in 4 and newer browsers.

Good Luck!
 
DeZiner,

Thanks for the reply, but this works and hides to blocks at the same time:

<html>

<body>

<div style=&quot;display:none&quot;>
<table>
<tr>
<td>row 1</td>
</tr>
<tr>
<td>row 2</td>
</tr>
</table>
<table>
<tr>
<td>
other table
</td>
</tr>
</table>
</div>

</body>
</html>

It just seems like a <div> within a table doesn't work.

Erin
 
I see that now, didn't understand the pariculars in the first post. Just create a class then, for IE anyway and apply the class to the cells you want to hide.
 
The reason your first example doesn't work is because anything within a <table> tag that is outside a <td> or <th> will be placed in front of the table... So your example is rendered like this:

<div style=&quot;display:none&quot;></div>
<table>
<tr><td>hi</td></tr>
<table>
 
aperfectcircle,

Thanks! Now it all makes sense.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top