Steven Lu
Steven Lu

Reputation: 43427

Setting margin and padding for <input type='radio' /> in css?

I can't seem to get the CSS to modify my radio buttons. Their default settings aren't symmetrical so my layout looks a little ugly. I am generating a bunch of these forms with javascript. I do not want to inject large amounts of inline style='margin:0px padding:0px' stuff but it's the only way I can get it to work.

Upvotes: 0

Views: 8035

Answers (1)

Sajid
Sajid

Reputation: 4421

Using a CSS selector, you can probably do this:

input[type=radio] { margin: 0; padding: 0; }

Note however that older versions of IE don't support attribute selectors. For those, you can do:

<div class="radios">
   ...input tags...
</div>

and

.radios input { margin: 0; padding: 0; }

to catch the oldies. This would cut down the amount of presentational code while maintaining compatibility with ie6.

Upvotes: 4

Related Questions