FAQ: Learn HTML: Forms - Password Input

This community-built FAQ covers the “Password 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 Password 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!

Is there a way to chose between * or • displayed on the input box when writing?


4 posts were split to a new topic: What about encrypting our passwords?

14 posts were split to a new topic: Are name, id, and for required? Can they be the same? And what is the relationship between them?

4 posts were split to a new topic: Does the order of attributes matter?

2 posts were split to a new topic: Why don’t we need the action and method attributes anymore?

4 posts were merged into an existing topic: Does the order of attributes matter?

I’m sorry, I’m a little lost.

Why are we adding the ‘for’ attribute?

And why does it have to be the same as the ‘id’ attribute?

Please and thank you!

What do you mean? Please explain throughly.

Sorry about that.

In the lesson:
The <label> element has an opening and closing tag and displays text that is written between the opening and closing tags. To associate a <label> and an <input> , the <input> needs an id attribute. We then assign the for attribute of the <label> element with the value of the id attribute of <input>

What is the ‘for’ attribute, well… for? What does it do?

And why does the ‘for’ value have to be the same as the ‘id’ value?

I don’t know why I’m having such a hard time with this particular lesson…

1 Like

I suggest you check out this article so that you can understand labels. Hopefully you will understand.

Happy coding! :wave:

Because this way, the browser knows which label is associated with which input field. Which is needed for screen readers (for people with poor vision for example)

Why we need <label> in this example

  <label for="user-password">Password: </label>
  <input type="password" id="user-password" name="user-password">

We can eliminate the <label>

> <form>
>   Password: <br>
>   <input type="password" id="user-password" name="user-password">
> </form>
1 Like

This topic is covered with answers to this question. Did you read some of them:

My code doesn’t work despite being exactly what it says in the textbox and working fine in the actual editor

<label for="Password">Password:</label>
    <input type="password" name"user-pw" id="user-pw">

the for attribute associates the label with the input element, using the id attribute of input element

those two values do not match

1 Like

Ah, thank you. Should this work?

    <label for="user-pw">Password: </label>
    <input type="password" name"user-pw" id="user-pw">



you miss an equal sign between the attribute and the value

1 Like

Oh my god, Im so dumb. Thank you

For the password input HTML element, why does the closing tag not have a forward-slash?