Skip to content
Advertisement

How can I stop these ‘s using space when I hide the labels?

I have 5 radio buttons, every one, when it is pressed, calls the function that hides/shows the input labels that I need.

I used document.getElementById("id").style.display="none"; and it works, but it still takes space.

I want the inputs of the form to fill the space above them when the elements above them are hidden. I think the problem is the <br> tags to separate the inputs, how can I fix this?

JS function:

JavaScript

HTML Inputs (are in a form if it matters):

JavaScript

Advertisement

Answer

<br> is meant to be used for line-breaks in text, not for general layouts.

As an alternative, you could set the form to display: flex; instead:

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement