<!-- :checked -->
<section class="example-cntr checked">
    <h1>CSS <code>:checked</code> pseudo-class</h1>
    <p>The <code>:checked</code> pseudo-class targets <code>radio buttons</code>, <code>checkboxes</code> or <code>option</code> elements that have been checked or selected.</p>
    <p>In this example, when the checkbox is selected, the label is highlighted to improve the UX.</p>
        <input type="checkbox" id="checked">
        <label for="checked">I agree with the Terms &amp; Conditions</label> 
$r: #c03;
$g: #429032;
$b: #2963BD;
$y: #c90;

:checked + label {
    background: $g;
    transition: .3s;

//Styling stuff not needed for demo
body { text-align: left; }
.example-cntr {
    max-width: 800px;
    margin: auto;
    padding: 20px 50px;    
    box-shadow: 0 1px 2px rgba(black,.3);
    background: rgba(black,.15);    
h1 {
    text-transform: none;
    border-bottom: #636363 1px dotted;
    code {
        display: inline-block;
        margin-bottom: 10px;
        color: $y;
        background: none;
        box-shadow: none;
code { font-size: 1em; }
form {
    width: 400px;
    margin: 40px auto 20px;
    padding: 40px 20px;
    border-radius: 2px;
    font-size: 1.2em;
    text-align: center;
    background: rgba(black,.2);
input, label { cursor: pointer; }
input {
    width: 34px; height: 34px;
    vertical-align: middle;
    outline: none;
label {
    padding: 3px 8px 5px;
    border-radius: 2px;
    border: transparent 1px solid;    
    transition: .5s;
    &:hover {
        border: rgba(white,.2) 1px solid;        

View Compiled

External CSS

  1. https://s3-us-west-2.amazonaws.com/s.cdpn.io/9988/codepen-base_3.scss

External JavaScript

This Pen doesn't use any external JavaScript resources.