{"id":9232,"date":"2011-05-02T11:08:04","date_gmt":"2011-05-02T18:08:04","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=9232"},"modified":"2011-05-02T11:08:04","modified_gmt":"2011-05-02T18:08:04","slug":"custom-radio-buttons","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/snippets\/css\/custom-radio-buttons\/","title":{"rendered":"Custom Radio Buttons"},"content":{"rendered":"
#foo:checked::before,\r\ninput[type=\"checkbox\"] {\r\n    position:absolute;\r\n    clip: rect(0,0,0,0);\r\n    clip: rect(0 0 0 0);\r\n}\r\n\r\n#foo:checked,\r\ninput[type=\"checkbox\"] + label::before {\r\n    content: url('checkbox.png');\r\n}\r\n\r\ninput[type=\"checkbox\"]:checked + label::before {\r\n    content: url('checkbox-checked.png');\r\n}<\/code><\/pre>\n

#foo doesn’t reference any particular element, it’s there purely to prevent browsers from implementing the later selectors if it doesn’t understand that (since most browsers will drop the entire selector if any part of it fails). <\/p>\n","protected":false},"excerpt":{"rendered":"

#foo:checked::before, input[type=”checkbox”] { position:absolute; clip: rect(0,0,0,0); clip: rect(0 0 0 0); } #foo:checked, input[type=”checkbox”] + label::before { content: url(‘checkbox.png’); } input[type=”checkbox”]:checked + label::before { content: url(‘checkbox-checked.png’); } #foo doesn’t reference any particular element, it’s there purely to prevent browsers from implementing the later selectors if it doesn’t understand that (since most browsers will drop the […]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":3222,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-snippet.php","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":""},"tags":[],"acf":[],"jetpack-related-posts":[{"id":15146,"url":"https:\/\/css-tricks.com\/snippets\/css\/custom-checkboxes-and-radio-buttons\/","url_meta":{"origin":9232,"position":0},"title":"Custom Checkboxes and Radio Buttons","date":"November 23, 2011","format":false,"excerpt":"The selectors here are specific to Wufoo markup, but the concepts at work can work for any form. The overall idea is that you make the default radio buttons and checkboxes invisible by setting their opacity to zero, and replace them with graphics. Then use the :checked selector to alternate\u2026","rel":"","context":"With 21 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14166,"url":"https:\/\/css-tricks.com\/almanac\/selectors\/c\/checked\/","url_meta":{"origin":9232,"position":1},"title":":checked","date":"February 17, 2013","format":false,"excerpt":"The :checked pseudo-class in CSS selects elements when they are in the selected state. It is only associated with input () elements of type radio and checkbox . The :checked pseudo-class selector matches radio and checkbox input types when checked or toggled to an on state. If they are not\u2026","rel":"","context":"With 45 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14174,"url":"https:\/\/css-tricks.com\/almanac\/selectors\/d\/default\/","url_meta":{"origin":9232,"position":2},"title":":default","date":"September 6, 2011","format":false,"excerpt":"The :default pseudo selector will match the default in a group of associated elements, such as the radio button in a group of buttons that is selected by default, even if the user has selected a different value. input[type=\"radio\"]:default + label:after { content: ' (default)'; color: #999; font-style: italic; }\u2026","rel":"","context":"With 5 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14180,"url":"https:\/\/css-tricks.com\/almanac\/selectors\/e\/enabled\/","url_meta":{"origin":9232,"position":3},"title":":enabled","date":"April 18, 2013","format":false,"excerpt":"The :enabled pseudo-class in CSS selects focusable elements that are not disabled, and therefore enabled. It is only associated with form elements (,