Youssef Youssef - 1 year ago 98
HTML Question

Hide div but keep the empty space

I have the following div


.description {
color: #b4afaf;
font-size: 10px;
font-weight: normal;


<div class="description">Some text here </div>

Then I have a click function on an element to hide the above div:


When I hide the div it will collapse (stop taking any space). This is messing with the layout of my page.

Is there a way I can hide the div but still take the space that it was taking before? I dont want to change the font color because it would be still selectable.


Answer Source

Use visibility css property for this


The visibility property specifies whether the boxes generated by an element are rendered.

$(".description").css('visibility', 'hidden');

Demo: Fiddle

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download