user262430 user262430 - 7 months ago 10
HTML Question

How to not have label text wrap under radio/checkbox input?

What is the cleanest and easiest way to not have label text wrap under radio/checkbox input. The solution should work in fluid/responsive layouts, in all browsers, and preferably be backwards compatible. I have provided a JSFiddle below.

http://jsfiddle.net/897vc9gx/

HTML CODE

<ul>
<li>
<input name="item1" id="item1" type="checkbox">
<label for="item1">
Select this if the answer is yes<br/>
<span>1111111111111</span>
</label>
</li>
<li>
<input name="item2" id="item2" type="checkbox">
<label for="item2">
Select this if the answer is maybe<br />
<span>1111111111112</span>
</label>
</li>
<li>
<input name="item3" id="item3" type="checkbox">
<label for="item3">
Select this if the answer is no<br />
<span>1111111111113</span>
</label>
</li>
</ul>


CSS CODE

ul{
list-style:none;
margin:0;
padding:0;
}

li{
margin-bottom:10px;
}

Answer

http://jsfiddle.net/897vc9gx/1/

HTML CODE

<ul>
<li>
    <input name="item1" id="item1" type="checkbox">
    <label for="item1">
        Select this if the answer is yes<br/> 
        <span>1111111111111</span>
    </label>
</li>        
<li>
    <input name="item2" id="item2" type="checkbox">
    <label for="item2">
        Select this if the answer is maybe<br />
        <span>1111111111112</span>
    </label>
</li>             
<li>
    <input name="item3" id="item3" type="checkbox">
    <label for="item3">
        Select this if the answer is no<br />
        <span>1111111111113</span>
    </label>
</li>
</ul>

CSS CODE

ul{
list-style:none;
margin:0;
padding:0;
}

li{
margin-bottom:10px;
}

input{
float:left;
margin-right:10px;
}

label{
overflow:auto;
display:block;
}