css - aligning a checbox next to a <td> in html -


i have basic css/html question using html/css. thought basic , obvious, not working intended.

http://puu.sh/2luhq.png

in basic image, want labels to right of expertise

(creating registration page user selects his/her expertise)

i believe basically

 <tr>   <td>expertise</td>   <input type="checkbox" style="vertical-align: left; margin: 12px;"> label </input><br>               <input type="checkbox" style="vertical-align: left; margin: 12px;"> label 2 </input>  </tr> 

however not working intended.

first of markup invalid, table element can have elements meant table child elements i.e tbody, thead, th, tr, td etc, , no other elements, instead can place checkboxes inside td

secondly input tag doesn't have explicit closing tag, need self close it, else leave without closing <br>

third - use label tag instead of having stray text besides checkbox

demo

the right way

<table>   <tr>     <td class="valign">         expertise     </td>     <td>         <input type="checkbox" style="vertical-align: left; margin: 12px;" />         <label>label</label><br />         <input type="checkbox" style="vertical-align: left; margin: 12px;" />         <label>labe2</label>     </td>   </tr> </table> 

css

.valign {     vertical-align: top; } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -