Forum Moderators: not2easy

Message Too Old, No Replies

Positioning Radio Buttons in a Row

Can't get all buttons and labels on the same row.

         

itKiwi

5:42 pm on Feb 7, 2009 (gmt 0)

10+ Year Member



I want to use a pair of radio buttons, and want all elements to be in the same row as the main label on the left. I have tried all sorts of things, but always get something screwy like in the example.

Appreciate any advice offered.
Thanks.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<style type="text/css">

div.form{
width: 320px;
}

fieldset{
border: 1px solid #000000;
width: 290;
}

legend
{
color: #000000;
/* background: #ffa20c;
border: 1px solid #781351; */
padding: 2px 6px
}

label{
float: left;
width: 100px;
text-align: right;
margin-right: 5px;
}

input, textarea{
width: 180px;
margin-bottom: 5px;
}

.boxes{
width: 1em;
}

#submitbutton{
margin-left: 105px;
margin-top: 5px;
width: 90px;
}

br{
clear: left;
}

</style>
<title>Test Form</title>
</head>

<body>
<div class="form">
<form>
<fieldset>
<legend>Complete this form</legend>
<label for="user">Name:</label>
<input type="text" name="user" value="" /><br />

<label for="emailaddress">Email:</label>
<input type="text" name="emailaddress" value="" /><br />

<label for="terms">Public:</label>
<label for="yes">Yes</label><input type="radio" value="Yes" checked="checked" />
<label for="no">No</label><input type="radio" value="No"/><br />

<input type="submit" name="submitbutton" id="submitbutton" value="Submit" />
</fieldset>
</form>
</div>
</body>

itKiwi

2:59 pm on Feb 9, 2009 (gmt 0)

10+ Year Member



Any ideas, please ? Is clarification needed ? Have I offended anyone ?
Thanks

londrum

3:21 pm on Feb 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



it's because they are too wide, you have something in your css which says
input, textarea{

width: 180px;

margin-bottom: 5px;

} 

...the radio buttons are input's too, so they are also 180px.
if you reduce the width of the radio inputs, then it should be alright i reckon.

redfoxhound

8:34 pm on Feb 9, 2009 (gmt 0)

10+ Year Member



It's not the radio box that's too wide, its the label tag. You need to reduce your label widths for those radios in order for them to be side by side.

itKiwi

9:32 am on Feb 12, 2009 (gmt 0)

10+ Year Member



Sorry about the delay. Thanks for both your replies. Got me thinking and experimenting with coloured backgrounds.Changed the button width to 20px, and a couple of other things, and now, it's great! Thanks again.