I have an issue with an HTML radio button and its label. I want to keep the radio button and label in the same line. But if the label text is very long, the label will sit below the radio button.
html:
<div class="form-check fs-3 mb-3">
<input id="low-3" name="low-3" type="radio" value="light">
<label for="low-3">very long very long very long very long context</label>
</div>
How can I keep the label on the same line as the radio button?
3
Answers
Now your label has inline-block display property so your elements on different lines. Wrap the input and the label and set "d-inline" class for the label and your elements will be on the same line.
Like this:
Problem
Bootstrap’s
_reset.scss
file setslabel { display: inline-block; }
by default, as you can see in the screenshot below.Solution
Simply set the Bootstrap
d-inline
class on the<label>
, which is equivalent tolabel { display: inline; }
.See the snippet below.
From what I understood, here’s my code, let me know if you’ve a more specific question.
Output: