Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change spacing between radio button and its text?

Tags:

html

css

I have the following HTML:

<input type="radio" name="beds" value="1" />1+  <input type="radio" name="beds" value="2" />2+

How do I change the spacing between the radio button and the "1+" text? I'd like the text to be closer to the radio button, but the browser is inserting a certain amount of undefined padding between the two elements.

like image 519
nickb Avatar asked Sep 07 '10 01:09

nickb


People also ask

How do you put space between radio button and text in HTML?

The margin-right: 25px creates the space because the input tag is a radio, the text doesn't count into it. So it is just the little rond and if you write in your CSS to put a space at the right of it, it will put the space between the text and the rond input element.

How do you put a space between text and button?

You can add more space between a button and text box by using “margin” attribute. If you want to add right side more space then add “margin- right”, for left side “magin-left”, for top side “margin-top”, for bottom “margin-bottom”.

How do I reduce the space between radio buttons in css?

Just change the input id's width to auto in css.


1 Answers

Many HTML elements have a default margin setting. You can override this and set it to 0. In your case, you want to reset margin-right on the radio button:

<input type="radio" name="beds" value="1" style="margin-right: 0" />1+ 

You probably want to add it to your stylesheet so that it applies to all radio buttons:

input[type="radio"] {   margin-right: 0; } 
like image 175
casablanca Avatar answered Sep 19 '22 23:09

casablanca