S
Stevo
Can anyone explain why in this simple example code below, the yellow
background color goes across the whole width of the page? You can see
that the image is only 300 pixels wide (I've also tried using a table
instead of an image) yet the DIV expands to the full width of the page.
It doesn't expand to the whole height of the page, only the width.
<html><body>
<div style="display:block;background-color:yellow">
<img width=300 height=300>
</div>
after text
</body></html>
When I inspect the DIV using IE's MS Dev Toolbar's DOM Explorer, the
height of the DIV is 304 pixels (it gained 4 pixels somehow) and the
width is whatever width I have the browser sized at (I won't be
surprised if it's gained 4 pixels there also). Anyone know why I'm not
seeing both fixed at 300 ?
If I set margin:0;padding:0;border:0 in the style of the DIV it makes no
difference (I do see all the values set to 0px in the Dev Toolbar DOM
Explorer).
I can't do anything outside of that DIV (like putting the DIV inside a
table), although that would seem like a hack anyway. Is there anything I
can do inside, like use a different spacer method, or a nested DIV
(which I've also tried, but perhaps with the wrong style properties).
background color goes across the whole width of the page? You can see
that the image is only 300 pixels wide (I've also tried using a table
instead of an image) yet the DIV expands to the full width of the page.
It doesn't expand to the whole height of the page, only the width.
<html><body>
<div style="display:block;background-color:yellow">
<img width=300 height=300>
</div>
after text
</body></html>
When I inspect the DIV using IE's MS Dev Toolbar's DOM Explorer, the
height of the DIV is 304 pixels (it gained 4 pixels somehow) and the
width is whatever width I have the browser sized at (I won't be
surprised if it's gained 4 pixels there also). Anyone know why I'm not
seeing both fixed at 300 ?
If I set margin:0;padding:0;border:0 in the style of the DIV it makes no
difference (I do see all the values set to 0px in the Dev Toolbar DOM
Explorer).
I can't do anything outside of that DIV (like putting the DIV inside a
table), although that would seem like a hack anyway. Is there anything I
can do inside, like use a different spacer method, or a nested DIV
(which I've also tried, but perhaps with the wrong style properties).