display:none ignored

W

Willem Alberda

Hi

If I create a small html file with the following lines

<table>
<span style='display:block'><tr><td>Number one</td></tr></span>
<span style='display:none'><tr><td>Number two</td></tr></span>
<span style='display:block'><tr><td>Number three</td></tr></span>
</table>

all three lines are displayed while I expected that "Number two" would be
hidden.

If I remove the <table> and </table> tags, it indeed only shows the first
and the third line, so somehow the table interferes here, but I don't know
why or how.

Can someone explain please?

Thank you
Willem Alberda
 
M

Michael Fesser

..oO(Willem Alberda)
If I create a small html file with the following lines

<table>
<span style='display:block'><tr><td>Number one</td></tr></span>
<span style='display:none'><tr><td>Number two</td></tr></span>
<span style='display:block'><tr><td>Number three</td></tr></span>
</table>

It's invalid code.

Micha
 
B

Beauregard T. Shagnasty

Willem said:

Good morning.
If I create a small html file with the following lines

<table>
<span style='display:block'><tr><td>Number one</td></tr></span>
<span style='display:none'><tr><td>Number two</td></tr></span>
<span style='display:block'><tr><td>Number three</td></tr></span>
</table>

<table>
<tr><td><span style='display:block'>Number one</span></td></tr>
<tr><td><span style='display:none'>Number two</span></td></tr>
<tr><td><span style='display:block'>Number three</span></td></tr>
all three lines are displayed while I expected that "Number two" would be
hidden.

...and there will still be a space for the table row.
If I remove the <table> and </table> tags, it indeed only shows the
first and the third line, so somehow the table interferes here, but I
don't know why or how.

<span> is an inline element, and cannot contain a block level element.
The validator would have told you this.

Now ... would a *list* be more appropriate for the above, instead of a
table?
 
J

Jonathan N. Little

Beauregard said:
Willem Alberda wrote:
<table>
<tr><td><span style='display:block'>Number one</span></td></tr>
<tr><td><span style='display:none'>Number two</span></td></tr>
<tr><td><span style='display:block'>Number three</span></td></tr>
</table>

<span> is an inline element, and cannot contain a block level element.
The validator would have told you this.

Now ... would a *list* be more appropriate for the above, instead of a
table?
Agreed!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Better way</title>

<style type="text/css">
.NoSee { display: none; }
</style>
</head>
<body>
<ul>
<li>Number one</li>
<li class="NoSee">Number two</li>
<li>Number three</li>
</ul>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top