fmz 14

I am using a table to display a series of radio buttons for selection. They populate fine and work correctly, but I am having an odd time trying to position the radio buttons in the table cells. I would like to position them in the center.

Here is the obvious code:

<tr class="even">
        <td><label for="ln_th_6-7">Th 6-7</label></td>
        <td><input type="radio" name="ln_th_6-7" value="mary"/></td>
        <td><input type="radio" name="ln_th_6-7" value="joseph"/></td>
        <td><input type="radio" name="ln_th_6-7" value="wiseman1"/></td>
        <td><input type="radio" name="ln_th_6-7" value="wiseman2"/></td>
        <td><input type="radio" name="ln_th_6-7" value="wiseman3"/></td>
        <td><input type="radio" name="ln_th_6-7" value="shepherd1"/></td>
        <td><input type="radio" name="ln_th_6-7" value="shepherd2"/></td>
</tr>

I tried this, but it didn't work as I had hoped:

margin: 0 auto;
padding: 0 auto;

Thanks in advance for the help.

2 answers

Saiyan 113
1
point
This was chosen as the best answer
tr td{
            text-align: center;
        }

you could simply use this css to horizontal align the every inline element to the center of a tablecell.

Answered over 8 years ago by Saiyan
  • This solved the problem. I had tried td { text-align: center } but adding the tr made it work. Thanks. fmz over 8 years ago
danwellman 5600
1
point

You could maybe use vertical-align:middle; as well, but...

Using a table to layout form elements in this way in not how it should be done. The radio buttons are not tabular data are therefore should not be in a table. Aside from whether or not you should use a table for layout, the point is you shouldn't need to :)

Answered over 8 years ago by danwellman
  • Dan, normally, I wouldn't use a table, but this is for selecting roles during a specific time slot, so it really is tabular data. fmz over 8 years ago