Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make new lines in CSS in form for each label

Tags:

html

css

forms

I have HTML code

<form id="answers">
blue
<input id="0" type="radio">
red
<input id="1" type="radio">
pink
<input id="2" type="radio">
<input type="submit">
</form>

and I want to have each element in the new line. I don't want to use stuff like <br>. In CSS file I tried do this: display: block but nothing's changed.

like image 491
Jensky Avatar asked Oct 27 '25 06:10

Jensky


1 Answers

#answers input {display: block;}

this will make every input in its own line. If you wish to have every input with its label together in a line you should do something like

<form id="answers">
    <label>blue <input id="0" type="radio"></label>
    <label>red <input id="1" type="radio"></label>
    <label>pink <input id="2" type="radio"></label>
    <input type="submit">
</form>

css: #answers label {display: block;}

http://jsfiddle.net/barakedry/y6p54vzg/

like image 60
Barak Avatar answered Oct 29 '25 20:10

Barak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!