Dev Helpers
← Back

Change a label when its input is checked

Change a label when its input is checked with native CSS. The preview includes a small shared demo stylesheet.

Open this example in the interactive library

Source code

<style>
  .demo:checked + label {
    font-weight: 700;
    color: #0f766e;
  }
</style>
<input class="demo" type="checkbox" id="flag" /><label for="flag"
  >Show completed</label
>