Hidden HTML elements take space

Mike D picture Mike D · Sep 13, 2010 · Viewed 22.8k times · Source

I'd like to make some empty hidden elements (iframes would be nice, paragraphs would do) that Javascript would later fill and modify. I have not been able to figure out how to keep these elements from taking up space. I've turned off margins and padding and set height to zero but still end up with blank space.

I'd like to see an example of an hidden element that takes no space on the page. Actually, I'd like to see the HTML, CSS, and Javascript. :-).

Answer

Jess picture Jess · Sep 13, 2010

If you're using visibility: hidden; you should be using display: none; instead.