show/hide div without the hidden taking up space in Javascript

wilri01
wilri01 used Ask the Experts™
on
When I have a <div> or <table> using the style visibility:visible/hidden attribute in IE6, the hidden element takes up space. I need the hidden element to not take up space in the page.

Is the only way to do this by using the DOM to insert/delete the element?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Use a span tag.
Senior Software Developer
Commented:
display:none
vs
display:block

rather than

visibility:anything.

visibility controls whether or not you can see it.

display controls whether or not it is rendered (as such).

Commonly,

<div id="something" style="display:none;">hidden div</div>

and then using JS to show/hide the div.

$('something').show();
or
$('something').hide();

if using PrototypeJS (I guess there is similar code for JQuery).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial