02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Creating HTML5 Forms: Labels

Once you created an input tags it's always a great idea to add to it a label. Why? Labels help users that are visually imparted understand what there expected to enter into the field and they help search engines understand your page better, a win win.

Video Transcript

00:00Use a name password. Yeah, exactly. All right, so welcome back
00:04So in that we just learned how to create two inputs one was the type of text the other was a type password
00:10The next thing that we want to do is add a label to those inputs. So let's do that right away. Oh
00:17Screw that. Oopsie. I did it again. Yeah shit
00:28All right. So the first thing that we're gonna do is we're gonna add a new label
00:32So I'm just gonna put here in an elude line
00:34I'm gonna call it label and the label itself. I'm gonna give it a four four and then give it a name
00:40Now the name itself we need a first of all for the label itself once we give that name
00:46We could close it and now we're going to figure out what that name is
00:49We really want to link between our label and what our first input to do that
00:54I'm gonna give my input ID and I'm gonna call that ID
01:03user
01:05Once I've done that now, I'm ready that I have my input and that input has a unique ID which is called user
01:11I could say that this label is for the user
01:14Now what I did by this is that I linked between the two now
01:17The reason why this is important is more for users with disabilities
01:21It makes sure that the use a user with a disability has the clear understanding that this label is
01:27Connected this input device making sure that you could put that description or information what the user needs to put inside in a much
01:33More clear way for the visually impaired. All right, so I'm gonna put here
01:37The label of user and I'm gonna put here whatever copy I want for my user and I'll just break a line
01:43Let's do this again also for our password. So again for my password. I'm gonna give it an ID and
01:53I'm going to type that I'll call it
01:55Maybe pass for password and I could copy this label again and just change information
02:02Instead of this label being for the user this label is going to be for the password
02:07We could change the copy that will be shown to password
02:12If we save this we broke a line and say this we should be able to see now in two lines
02:16We should see our label and our passwords will have your user and password and it's already for us to type in our user
02:23Which would be 0 to geek and our password which would be 1 2 3 4 in this case. All right
02:29cool

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!