FAQ: Learn HTML: Forms - Number Input


This community-built FAQ covers the “Number 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 Number Input

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

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!


I am confused about the order when using the element.

Coming from passwords we were given the example:

       <input type="passwords">

So I used that for numbers, writing:

   <form action="/practice.html" method="POST">
        <label for="numbers"></label>
            <input type="number" id="amount" name="amount" step="1">

This was marked as wrong as it was meant to be:

   <form action="/practice.html" method="POST">
       <label for="numbers"></label>
          <input id="amount" type="number" name="amount" step="1">

Can anyone explain how I am meant to know the ordering and why it differs? I am enjoying codecademy but it doesn’t explain why something I have done is wrong! So then I am just trying and trying to until I get it right, but don’t really feel I understand why it was ever wrong?

Thanks in advance!


Actually ordering doesnt matter your id doesnt match the label thats why it showed wrong


This was the wrong one:

<form action="/practice.html" method="POST"> <label for="numbers"></label> <input type="number" id="amount" name="amount" step="1"> </form>


<input id="amount">

is incorrect. It should be same as <label for="numbers">

Solution: use id in <input id="numbers">. The sequence does not matter.


Are the “name” and “id” always the same? what is an example of when we would need them to be different?


Hello and welcome on the site :grinning:
They can be different, Id is to identify the element in CSS or in JS, name is to identify element in HTML and in PHP for form handling

Hope this helps :grinning:


What does step mean? Or step=1 mean? It didn’t explain it, it just said to do it. Help?


step defines how much should it jump once you decrease or increase it, so if step is 2 then when I click up it will be incremented by 2

Hope this helps :grinning:


I’ve noticed that the instructions mention name but not id, however to pass the code you need to have both.


Use name attributes for form controls, as that’s the identifier used in the POST or GET call that happens on form submission.
Use id attributes whenever you need to address a particular HTML element with CSS, JavaScript or a fragment identifier.
It’s possible to look up elements by name too, but it’s simpler and more reliable to look them up by ID.
Name is used for form handling in PHP when a form is submitted via HTML, name doesn’t have to be unique on a page, as it can link other elements together.

Hope this helps :grinning: