CSS: how to make label appear right of the radio?
Asked Answered
P

6

10

Say I have the following mark up:

<label for="name">Name:</label>
<input type="radio" name="name" id="name"/>

The order of the tags appear to be proper to me (in a semantic sense: label before the thing you're labeling). But I want to display this as radio button first, followed by the label. How can I do that in CSS?

Plop answered 5/4, 2012 at 3:40 Comment(0)
M
16

You don't need CSS. Wrap your input in a label and put the text last.

<label><input type="radio" name="name" id="name"/>Name:</label>

Is that still semantic for you?

Or you could try the float.

Mo answered 5/4, 2012 at 3:43 Comment(0)
H
3

Tag order in this case doesn't matter. And even if it did, then it would be the other way around - first you would have to create the radio button, and then reference it in the label.

To answer your question: just do it in the order you want to display it

<input type="radio" name="name" id="name"/>
<label for="name">Name:</label>

fiddle http://jsfiddle.net/Jm2JR/1/..

Hobard answered 5/4, 2012 at 3:45 Comment(0)
S
2

write like this:

input{
 float:left;
}

Check this http://jsfiddle.net/3cLRg/

Sigman answered 5/4, 2012 at 3:44 Comment(0)
T
1
<label for="name" style="float:right;">Name:</label>

Tomtit answered 5/4, 2012 at 3:42 Comment(0)
E
1

try this:

<label style="position:relative; left:100px;" for="name">Name:</label>
<input type="radio" name="name" id="name"/>

2nd approach is :

<input type="radio" name="name" id="name"/>
<label for="name">Name:</label>
Elvinaelvira answered 5/4, 2012 at 3:47 Comment(0)
A
1

Hi you just define your input tag as like that

<label>Name:
<input type="radio" name="name" id="name"/></label>

<br />


<label>
<input type="radio" name="name" id="name"/> Name    
</label>
​

Live demo http://jsfiddle.net/rohitazad/bhBQn/1/

Agone answered 5/4, 2012 at 3:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.