FAQ: Learn HTML: Forms - Adding a Label

in the example used for the “adding a label” lesson there was a break between the label and the input - is the break necessary?

you could: remove the break element, see what happens. You could search online/consult documentation on what break (<br>) does. Understanding what break does, might shed some light if its necessary

1 Like

break is a JavaScript keyword. <br> is a line break

line break then

1 Like

Can you switch “for” and “id”?

does label for=“meal”, can change to label id=“meal”?

No, you can not. for is <label> specific attribute.

1 Like

The value for (for) attribute for the (label) element should be similar to the value of (id) attribute for the (input) element? thx

     <form>
	    <h1>Login to start creating a burger!</h1>
        <label for="username">Username</label>
        <br>
        <input type="text" name="username" id="username">
      </form>

I think its best that code academy put this benefits on some page to help new learners see the importance of things

1 Like