Skip to content

Instantly share code, notes, and snippets.

@ajaswa
Last active October 9, 2015 01:48
Show Gist options
  • Save ajaswa/3420187 to your computer and use it in GitHub Desktop.
Save ajaswa/3420187 to your computer and use it in GitHub Desktop.
Fancy radio buttons
.radios .radio label {
background-color: #fff;
color: #666;
display: inline-block;
border: 1px solid black;
margin: 4px;
padding: 4px;
}
.radios .radio input[type='radio'] {
display: none;
}
.radios .radio input[type='radio']:checked + label {
background-color: #666;
color: #fff;
}
<!doctype html>
<html>
<head>
<link href="fancy-radio-buttons.css" rel='stylesheet' type='text/css' />
</head>
<body>
<form>
<div class='radios'>
<span class='radio'>
<input id='radio1' name='radioset' type='radio' />
<label for='radio1'>radio 1</label>
</span>
<span class='radio'>
<input id='radio2' name='radioset' type='radio' />
<label for='radio2'>radio 2</label>
</span>
<span class='radio'>
<input id='radio3' name='radioset' type='radio' />
<label for='radio3'>radio 3</label>
</span>
</div>
</form>
</body>
</html>
@ajaswa
Copy link
Author

ajaswa commented Aug 22, 2012

Using display: none; makes the radio buttons inaccessible for screen readers and keyboard users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment