4

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.

Jensky
  • 919
  • 3
  • 12
  • 26

2 Answers2

10
#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/

Barak
  • 1,148
  • 7
  • 13
0

You may need to use box-sizing:border-box;.

There's more information on this very topic in this thread: input with display:block is not a block, why not?

Community
  • 1
  • 1
tommymcdonald
  • 1,528
  • 2
  • 10
  • 12