Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (20.3k points)

I want to have a hidden checkbox that doesn't take up any space on the screen.

If I have this:

<div id="divCheckbox" style="visibility: hidden">

I don't see the checkbox, but it still creates a new line.

If I have this:

<div id="divCheckbox" style="visibility: hidden; display:inline;">

it no longer creates a new line, but it takes up horizontal space on the screen.

Is there a way to have a hidden div that takes up no room (vertical or horizontal?

1 Answer

0 votes
by (40.7k points)

Try using display:none;

<div id="divCheckbox" style="display: none;">

  • visibility: hidden hides the element, but it still takes up space in the layout.
  • display: none removes the element completely from the document, it doesn't take up any space.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...