FAQ: Learn HTML: Forms - Checkbox Input

This community-built FAQ covers the “Checkbox Input” exercise from the lesson “Learn HTML: Forms”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Introduction to HTML

FAQs on the exercise Checkbox Input

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

3 posts were split to a new topic: Code was already entered?

14 posts were split to a new topic: What is the purpose of the value attribute?

7 posts were split to a new topic: What if I want to limit the number of check boxes that can be selected?

10 posts were split to a new topic: Does the order of label and ID matter?

A bit unrelated but when I added a min and max to the amount of patties you can have the text displayed changed even though there was no actual text added. why is that?

2 posts were split to a new topic: How does the for attribute work?

For this lable <label for="tomato">Tomato</label> if I use <input type="checkbox" id="lettuce" name="topping" value="lettuce"> than also I am getting correct output(i.e. checkbox above tomato !) . Why ? There is no difference whether I use id =“lettuce” or id=“tomato” in tomato label ?

That would totally mess with a screen reader since it would telling the user something entirely different than what one would be expecting. This does not require rocket science, and is easy to accept for the purpose it was intended.

In a form , while using multiple input tags having the same name attribute of type “checkbox”
input type=“checkbox”
when we select multiple checkboxes , how the information is stored and transferred from the form to the action attribute?
By information , I mean multiple values from the selected checkboxes (input tags).

The action attribute contains the URL of the form handler, typically a server-side script that parses the query string attached to the request. On the client side, form values are transformed into that query string on Submit. This is done internally by the browser.