From the course: HTML Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

More on forms

More on forms

- We're building a form for collecting a name and email address, so perhaps people can sign up for an email newsletter. At the moment, these two input elements both collect text, like any text. A user could type anything in there, even though one of them is supposed to be for an email field. That's because we haven't yet told the browser what type of input we want from these fields. Let's fix that by adding the type attribute to each input. For the name field we'll collect text, which is the default. If you leave type off, as we did in the last video, the browser will assume that it's type of text, so we don't have to include it. But why not, for completion's sake. Type equals text. Then for the email field, let's tell the browser we want to collect an email address, and get the browser to help our user fill out the form correctly. Type equals email. Now when people fill out this form, the browser will double-check,…

Contents