Start learning with our library of video tutorials taught by experts. Get started

HTML5 First Look

New input types


From:

HTML5 First Look

with James Williamson

Video: New input types

A quick glance at the form section of the HTML5 specification is all that you'll need to see that there are some significant upgrades to form elements. This is only natural as HTML5 focuses in large part on building applications and forms are a big part of almost any application you might build. In this chapter, I want to focus on some of the changes to the forms specification and show you what you can do with them in your own web sites and applications. We'll start by focusing on a form element that adds some very powerful new attributes, the input field.
Expand all | Collapse all
  1. 3m 56s
    1. Welcome
      1m 1s
    2. Using the exercise files
      1m 50s
    3. Who is this course for?
      1m 5s
  2. 21m 12s
    1. Exploring prior standards
      4m 26s
    2. Why do we need HTML5?
      3m 32s
    3. HTML5 timeline
      4m 24s
    4. Current HTML5 support
      4m 25s
    5. What HTML5 is (and what it isn't)
      4m 25s
  3. 27m 49s
    1. HTML5 vs. HTML4
      3m 25s
    2. New structural tags
      6m 1s
    3. New content tags
      4m 7s
    4. New application-focused tags
      5m 32s
    5. Deprecated elements
      4m 28s
    6. API overview
      4m 16s
  4. 22m 29s
    1. Content models
      5m 33s
    2. Understanding the outline algorithm
      3m 21s
    3. The role of ‹div› tags
      4m 20s
    4. Using ID and class attributes
      2m 6s
    5. DOCTYPE declarations
      4m 16s
    6. Character encoding
      2m 53s
  5. 41m 27s
    1. Basic page structure
      3m 40s
    2. Structuring top-level elements
      7m 30s
    3. Structuring interior content
      8m 42s
    4. Building headers
      9m 11s
    5. Checking document outlines
      5m 46s
    6. Ensuring cross-browser structure
      6m 38s
  6. 27m 53s
    1. New input types
      5m 57s
    2. Setting form autofocus
      2m 53s
    3. Using placeholder data
      4m 4s
    4. Marking required fields
      3m 24s
    5. Working with number inputs
      5m 49s
    6. Using date pickers
      5m 46s
  7. 1h 1m
    1. Canvas overview
      6m 21s
    2. Adding canvas content
      8m 58s
    3. Drawing in the canvas environment
      12m 9s
    4. Drag-and-drop API overview
      6m 18s
    5. Offline applications overview
      7m 11s
    6. Video overview
      5m 45s
    7. Encoding video
      8m 23s
    8. Adding video
      5m 58s
  8. 57m 33s
    1. Geolocation API overview
      5m 50s
    2. Web storage API overview
      5m 40s
    3. WebSockets overview
      4m 16s
    4. CSS3 overview
      6m 38s
    5. Enhancing typography with CSS3
      7m 42s
    6. Using @font-face
      7m 11s
    7. Styling HTML5 with CSS3
      10m 23s
    8. Using CSS3 transitions
      9m 53s
  9. 5m 6s
    1. Final thoughts
      3m 49s
    2. Goodbye
      1m 17s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
HTML5 First Look
4h 28m Beginner Aug 23, 2010

Viewers: in countries Watching now:

In HTML5 First Look, author James Williamson introduces the newest HTML specification, providing a high-level overview of HTML5 in its current state, how it differs from HTML 4, the current level of support in various browsers and mobile devices, and how the specification might evolve in the future. Exercise files accompany the course.

Topics include:
  • Understanding the history of HTML5
  • Using new tags
  • Understanding HTML5 semantics
  • Coding ID and class attributes in HTML5
  • Structuring documents
  • Building forms
  • Exploring HTML5 native APIs
  • Encoding and adding HTML5 video
  • Exploring associated technologies such as CSS3
Subjects:
Developer Web Web Design Web Development
Software:
HTML
Author:
James Williamson

New input types

A quick glance at the form section of the HTML5 specification is all that you'll need to see that there are some significant upgrades to form elements. This is only natural as HTML5 focuses in large part on building applications and forms are a big part of almost any application you might build. In this chapter, I want to focus on some of the changes to the forms specification and show you what you can do with them in your own web sites and applications. We'll start by focusing on a form element that adds some very powerful new attributes, the input field.

The input field is the most common form element used in building HTML forms. The multiple types of input fields make it easy to add text fields, radio buttons, checkboxes, and submit buttons to our forms. HTML5 adds a few new input field types that are going to make it a lot easier to build more responsive and more robust forms. Let's take a look. So here I've got the trails.htm from the 05_01 folder opened up. If I scroll down through the code, I can see that towards the bottom of this, where we used to have the Rider Review, we now have a form going on down here.

This is the form that lets people submit their own reviews. So not much else has changed. Notice that instead of an article now, it is now a section. We still have a header. We still have the hgroup up here, but the reason it changed from an article to a section is because the content really isn't standalone content anymore. This is not something that you're probably going to republish in another location. Okay, so if you look at the form, it's a pretty basic, very, very simple form. We've got a couple of text inputs, one for Trail name, one for Name, one for Email, one for the rider's web site, if they want to promote that.

Then we have a text area down here where they can submit the actual review. Now, there's going to be more to this form eventually. We're going to add some additional elements to it, but for right now, I want to focus on these input types. So our trailName is a text input and that sort of makes sense. Our name, first name last name, is a text input. That kind of makes sense. Having something to write their email in, that's a text input. That kind of makes sense. But in HTML5, we have new input types for our form elements. Let's take a look at a couple of those options. So I'm going to find the input for email.

So it's got a name of email and an ID of email. I'm going to go ahead and highlight the text value and I'm just going to type in email. You got it. It's that simple. So what that does is it converts the input type from just a normal text field to one that is expecting the input of an email address. Now, there are a couple of different things that are going to happen as a result of this. Most browsers and devices would just go ahead and treat this as a normal text field. So if they don't support the email type, no harm, no foul. They'll just treat it like a normal text type. However, if they do support the email text type, it's going to make form validation easier.

In the case of several devices, it's actually going to change the options for user input. Now, let's do the same thing down here for our web site. Again, its type is text, but I'm going to go ahead and highlight that and I'm going to show you something about the code hinting here too. It's going to allow me to go over some of these. I'm just going to open up a quotation mark, so I can see some of the types that are available to us now. Most of these you've probably noticed before, but things like date, datetime, that's new. There is email, we just used that. If I scroll down a little bit, I can see file. There's month, number, so some of these we're going to get into in just a little bit.

Here's telephone, time, and this is the one we're looking for, URL. You can also see week. That's a new one as well. So there's a lot of new ones in here in HTML5. I'm going to say URL and again what this is going to do for us is it's going to change the type of information that this text input field is expecting. It's going to be expecting a full URL. So again, different browser agents can choose how they react to that. It might change how the forms get auto filled. It might change how the interface's input options are laid out and it could certainly help with form validation and we're going to see that in just a little bit.

So I'm going to go ahead and save this file and I'm going to preview this page. I'm going to go ahead and open up this page in Opera. Okay, so here's our page opened in Opera. I'm going to scroll down to see our form. You can see right off the bat, there's something a little different going on here. The email form has a dotted line all the way around it. You may or may not see that. The reason that I see this is because I have my preferences in Opera set to auto fill out certain forms and one of the things that I have set in my Autofill Preferences is my Email address.

So it automatically sort of highlights this and says, "Look, if you choose to auto fill out this form, this is one of the fields that will be filled in." Now if I just tab through my form here, I don't really notice anything different. What's really odd about this is in previous versions of Opera, if I clicked an Email, I would literally have a link to my email contacts here and if I clicked in Website, I would have a link to all the bookmarks within the Opera browser. If you're using an older version of Opera, you might actually be seeing that, instead of what we're seeing here which is just the appearance of a normal form element. Now on the other hand, if we view this on a device and I'm just going to switch over here to an iPhone.

I'm going to pull up the same form. You'll notice here if I click inside one of the top two form elements, a keyboard comes up and allows me to type in my response. Now nothing new there. But if I go down and click inside the Email, notice the change in the keyboard that comes up. We now have the @ symbol, okay. So now if I scroll down and click inside the Website form element, there you go. You can see that the keyboard that comes up for that now has the .com. So the iPhone is sensitive to these different types of form elements. They're going to give the user a different way to interact with those form elements based on the type.

So, with some very minor changes to our code, we've added an additional functionality to our forms. Now currently, only some mobile devices like the iPhone and only certain browsers like Opera support any additional functionality for these form elements, but changing the type causes no issues in older browsers, which treat them just like normal text inputs and for that reason, I really don't see any reason not to start using these form elements right away.

There are currently no FAQs about HTML5 First Look.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed HTML5 First Look.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked