Whats wrong with DIV in Table?

M

Martin Schneider

Hello! I have the html-code attached. It is shown well in Firefox for
example, but in Internet-Explorer 6.0 "div3" with "My Div Text" is not
shown at all. When removing all the TABLE-Tags, it works in IE as well,
but I need the table. Any ideas why div3 is not shown? Can somebody
confirm the error or am I doing something wrong?

Martin


<HTML>
<BODY>

<div id="div1"
style="position:absolute;top:0px;left:0px;height:800px;visibility:visible;overflow:hidden;border:1px
solid black">
<div id="div2"
style="position:relative;left:0px;top:0px;border:0px;overflow-y:hidden;overflow-x:hidden;border:1px
solid black">
<TABLE ALIGN=LEFT BORDER="1" CELLPADDING="0" CELLSPACING="0">
<TR><TD ALIGN="LEFT" VALIGN="TOP">
<div id="div3"
style="position:relative;left:0px;top:0px;width:200px;height:100px;background:#FF0000;visibility:visible">
My Div Text
</div>
</TD></TR></TABLE>
</div></div>

</BODY>
</HTML>
 
R

Roy Schestowitz

Martin said:
Hello! I have the html-code attached. It is shown well in Firefox for
example, but in Internet-Explorer 6.0 "div3" with "My Div Text" is not
shown at all. When removing all the TABLE-Tags, it works in IE as well,
but I need the table. Any ideas why div3 is not shown? Can somebody
confirm the error or am I doing something wrong?

Martin


<HTML>
<BODY>

<div id="div1"
style="position:absolute;top:0px;left:0px;height:800px;visibility:visible;overflow:hidden;border:1px
solid black">
<div id="div2"
style="position:relative;left:0px;top:0px;border:0px;overflow-y:hidden;overflow-x:hidden;border:1px
solid black">
<TABLE ALIGN=LEFT BORDER="1" CELLPADDING="0" CELLSPACING="0">
<TR><TD ALIGN="LEFT" VALIGN="TOP">
<div id="div3"
style="position:relative;left:0px;top:0px;width:200px;height:100px;background:#FF0000;visibility:visible">
My Div Text
</div>
</TD></TR></TABLE>
</div></div>

</BODY>
</HTML>

Div inside a table? Isn't that a violation of HTML validity? Div can at
fixed positions as well so I wonder how this fits within a table. Someone
more knowledgeable will give a definite answer, I'm sure, but these are
just my 2 cents.
 
S

SpaceGirl

Roy said:
Martin Schneider wrote:




Div inside a table? Isn't that a violation of HTML validity? Div can at
fixed positions as well so I wonder how this fits within a table. Someone
more knowledgeable will give a definite answer, I'm sure, but these are
just my 2 cents.

No... a div can be anywhere text can be...

<table><tr><td><div>my text</div></td></tr></table>

....is perfectly valid. If the OP removes pos:rel, it might work.

--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
 
M

Martin Schneider

Thanks for all the answers.
No... a div can be anywhere text can be...

<table><tr><td><div>my text</div></td></tr></table>

...is perfectly valid. If the OP removes pos:rel, it might work.
Well, then it really DOES work, but I need to change the position to
pos:rel is exactly what it should be.

Martin
 
L

Leif K-Brooks

SpaceGirl said:
No... a div can be anywhere text can be...

No, a DIV element can be anywhere that block-level content can go. This
is not valid:

<span><div>foo</div></span>
 
N

Noozer

Leif K-Brooks said:
No, a DIV element can be anywhere that block-level content can go. This
is not valid:

<span><div>foo</div></span>

....so this is better?

<span><span style="display: block;">foo</span></span>

: )
 
T

Toby Inkster

Noozer said:
...so this is better?
<span><span style="display: block;">foo</span></span>

Yes. But this is the best:
<span><object><div>foo</div></object></span>
 
R

Richard

Hello! I have the html-code attached. It is shown well in Firefox for
example, but in Internet-Explorer 6.0 "div3" with "My Div Text" is not
shown at all. When removing all the TABLE-Tags, it works in IE as well,
but I need the table. Any ideas why div3 is not shown? Can somebody
confirm the error or am I doing something wrong?

Remove the "position" stuff. Not needed.
enter text into div 1 and 2 and you'll see what you've told IE to do.
without something definitive in the divisions, they do not appear.
That's kind of a quirk of IE.

Use position only to point an object in a specified location, such as your
table.
Absolute defines position from the top left corner of the browser window.
Relative defines position from the top lef corner of the container, a
division.
 
S

Steve Pugh

Richard said:
Absolute defines position from the top left corner of the browser window.

No it doesn't. It defines position relative to the containing block.
The CB is the closest ancestor element with position set to anything
other than static; if no ancestor element qualifies then the Initial
Containing Block is used. The ICB is usually the same as the browser
window.
Relative defines position from the top lef corner of the container, a
division.

No it doesn't. It defines position relative to the static position of
the element.

Steve
 

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

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,219
Latest member
KristieKoh

Latest Threads

Top