SwitchUp SwitchUp Ranked Best Coding Bootcamps 2025

Set checkboxes to checked by default

Altcademy Team wrote on 7 February 2018

This is not working.
<label><input type="radio " name="indoor-outdoor" checked by default> Indoor</label> <label><input type="radio" name="indoor-outdoor" checked> Outdoor</label> <label><input type="checkbox" name="personality"> Loving</label> <label><input type="checkbox" name="personality"> Lazy</label> <label><input type="checkbox" name="personality"> Energetic</label> <input type="text" placeholder="cat photo URL" required>

Just use the checked attribute, checked by default will not work. Here is the correct code.
<label><input type="radio " name="indoor-outdoor" checked> Indoor</label> <label><input type="radio" name="indoor-outdoor"> Outdoor</label> <label><input type="checkbox" name="personality"> Loving</label> <label><input type="checkbox" name="personality"> Lazy</label> <label><input type="checkbox" name="personality"> Energetic</label> <input type="text" placeholder="cat photo URL" required>

Trusted by

Students and instructors from world-class organizations

Join the upcoming Cohort #110

Enroll for February 2nd, 2026