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

Web Accessibility Principles
Illustration by

Labeling form fields


From:

Web Accessibility Principles

with Zoe Gillenwater

Video: Labeling form fields

>> In the last movie, we learned how important it is for form elements to be labeled so that all users can know what to fill in each field and can do so without too much trouble. In this movie we'll add labels to the form in the departments page of our example site. First let's talk about the different options for form labels. They can either be implicit or explicit. Implicit labels are wrapped around the form control that they label. This keeps the HTML very simple. But the problem is that this setup is not supported in older screen readers.
Expand all | Collapse all
  1. 2m 0s
    1. Welcome
      1m 3s
    2. Using the exercise files
      57s
  2. 33m 15s
    1. What does accessibility mean?
      5m 51s
    2. How does accessibility help your users?
      3m 30s
    3. Experiencing a website via a screen reader
      5m 46s
    4. How does accessibility help you and your clients?
      3m 9s
    5. Overview of Section 508 standards
      5m 51s
    6. Overview of WCAG standards
      6m 4s
    7. Understanding consistency and semantic markup
      3m 4s
  3. 54m 31s
    1. Understanding screen readers and accessibility tools
      6m 12s
    2. Getting accessible browsers
      5m 41s
    3. Customizing Firefox for accessibility testing
      5m 53s
    4. Using custom accessibility toolbars
      5m 28s
    5. Using Fangs and the Color Contrast Analyzer
      5m 30s
    6. Accessibility tools to bookmark
      5m 53s
    7. Using automated accessibility checking tools
      4m 57s
    8. Setting up the JAWS screen reader on Windows
      6m 42s
    9. Using the VoiceOver screen reader on Mac OS X
      5m 52s
    10. Setting Dreamweaver accessibility preferences
      2m 23s
  4. 26m 12s
    1. Avoiding tables for layout
      3m 30s
    2. Using CSS for layout
      2m 40s
    3. Creating a fixed-width layout
      5m 51s
    4. Creating an elastic layout
      3m 51s
    5. Creating a liquid layout
      3m 4s
    6. Customizing a liquid layout
      7m 16s
  5. 1h 6m
    1. Specifying the language
      3m 43s
    2. Setting page titles
      2m 16s
    3. Setting headings and paragraphs
      9m 55s
    4. Styling headings
      9m 56s
    5. Hiding section headings from sighted users
      6m 41s
    6. Styling text for readability
      6m 41s
    7. Ensuring proper color contrast
      6m 36s
    8. Creating text emphasis
      4m 29s
    9. Indicating quotations
      4m 29s
    10. Creating basic lists
      4m 16s
    11. Styling lists
      7m 15s
  6. 1h 15m
    1. Using lists for navigation
      6m 45s
    2. Creating a horizontal navigation bar
      13m 25s
    3. Creating a vertical navigation bar
      11m 44s
    4. Adding skip navigation links
      12m 0s
    5. Hiding skip navigation links
      6m 17s
    6. Proper link text and title attributes
      6m 11s
    7. Opening new windows
      4m 28s
    8. Accessibility limitations of fly-out menus
      6m 30s
    9. Creating an accessible fly-out menu
      8m 38s
  7. 27m 55s
    1. Proper ALT text for navigation images
      4m 57s
    2. Proper ALT text for decorative images
      5m 19s
    3. Adding ALT text to an existing site
      6m 9s
    4. Adding ALT text to image maps
      5m 58s
    5. Describing complex graphics
      5m 32s
  8. 34m 1s
    1. Using tables for data
      3m 0s
    2. Creating header cells
      4m 5s
    3. Adding table captions and summaries
      9m 9s
    4. Styling tables
      5m 19s
    5. Applying header cells to complex tables
      6m 52s
    6. Adding id and headers attributes
      5m 36s
  9. 42m 7s
    1. Understanding form accessibility issues
      3m 7s
    2. Labeling form fields
      6m 9s
    3. Adding fieldsets and legends
      4m 42s
    4. Moving forms out of tables
      3m 44s
    5. Cleaning up a form's appearance
      4m 53s
    6. Aligning labels and fields using CSS
      9m 39s
    7. Indicating required fields
      6m 15s
    8. Dealing with CAPTCHA
      3m 38s
  10. 7m 29s
    1. The Text-Only technique
      3m 21s
    2. The Access Keys technique
      2m 35s
    3. The Tab Index technique
      1m 33s
  11. 18s
    1. Goodbye
      18s

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 ...
Web Accessibility Principles
6h 10m Appropriate for all Oct 16, 2007

Viewers: in countries Watching now:

Accessibility on the web has been an issue for over a decade, and it remains a crucial--but often overlooked--element of web design. Instructor Zoe Gillenwater explains the concept of accessibility as it applies to the web, and describes how it affects the audience. She also covers how to set up accessibility testing, and how to apply accessibility principles to new and existing sites using standards-compliant markup and CSS. Exercise files accompany the tutorials.

Topics include:
  • Understanding Flex programming languages
Subjects:
Web User Experience Accessibility
Author:
Zoe Gillenwater

Labeling form fields

>> In the last movie, we learned how important it is for form elements to be labeled so that all users can know what to fill in each field and can do so without too much trouble. In this movie we'll add labels to the form in the departments page of our example site. First let's talk about the different options for form labels. They can either be implicit or explicit. Implicit labels are wrapped around the form control that they label. This keeps the HTML very simple. But the problem is that this setup is not supported in older screen readers.

It also makes it harder for you to style with CSS, as we'll see later. Explicit labels are placed separately from the form control, either before or after it, and they don't need to be right next to the form control. The connection then is made by an ID attribute on the form field itself and a for attribute with the same value for the label tag. This method is well supported and gives your more styling options with CSS, so let's use this label method on the departments page form that we looked at in the last movie.

If you're following along with the exercise files, open the page departments.html in Dreamweaver. It's located in the 08_02 folder of the chapter eight exercise files. This form does not currently have labels set on any of the fields. Select over the text name in the first row of the table. Now right click or control click on the highlighted text and choose quick tag editor. You'll be asked to wrap a tag around the highlighted text. Type label or choose it from the menu of tags shown.

We also need to add a for attribute so then type a space, then for="name". This is stating that we want this text to label a field that has an ID attribute of name. Click on the field beside the name label. Now we need to give the field that ID attribute so that they are connected. Right click or control click on the field next to name and click on edit tag in the menu shown.

The tag editor dialogue box appears. Click on the style sheet/accessibility category on the left hand side of the dialogue box. Click inside the ID field and type name. Then click okay. Let's go into code view to see how this has changed the HTML. Click on the code button in the documents toolbar. The input tag that we just edited will still be highlighted. You can see that it has a name attribute set, which is what is used by the form processing script.

Then it has a type attribute set, which determines what type of attribute it is. And then finally there's the ID attribute that we just added. We've given it the same value as the name attribute, but it doesn't have to have the same value. For instance, we could have given it an ID of field-name. If we did this we'd have to make sure that the for attribute of our label tag had this same value. This is a spot where the attributes must match. The for attribute on the label must have the same value as the ID attribute on the form control.

Go back to design view now by clicking on the design button in the document tool bar. Let's see how we would add a label when first inserting the form field. Place your cursor in front of the phone text in the form table. Go to the insert menu and choose table objects, then choose insert row above. Place your cursor inside the second cell of this new table row. Then go to the insert tool bar and click on the forms tab. Next, click the text field button, the second button from the left, to insert a new field.

The input tag accessibility attributes box appears. If we had not checked the form option under Dreamweaver's accessibility preferences as we did in an earlier movie, this dialogue box would not appear. Instead, it would simply insert the text field and not prompt you for a label. You could still add a label yourself later, but having this dialogue box servers are a good reminder to always add a label every time you add a form field. Click inside the label field first, type address: space, now click back inside the ID box.

Here's where we need to set the value of the ID attribute. Dreamweaver will also set it as the value of the for attribute when it creates the label for us. Type address. Next, in the dialogue box, we need to choose a style of label tag. The first option is to wrap with label tag. We've talked about why this isn't ideal, so choose the second option, attach label tag using for attribute. The next option asks you where you want to position the label, before the form item or after the form item. Keep before form item selected.

Don't worry about the access key or tab index items for now. We'll talk about them later. Click on okay. Let's go into code view to see the HTML that Dreamweaver created. Click on the code button in the document tool bar. The new field and its label are highlighted in HTML. If we look at the for attribute of the label, we can see that it matches the ID attribute of the input tag. Now we simply need to move the label out of this table cell into the first cell of the row. Highlight over the entire label element from its closing tag to its opening tag, then press control X or command X on your keyboard to cut the selection.

Next, highlight over the content of the cell immediately above the one we were just in then press control V or command V on your keyboard. Now click on the design button in your document tool bar. Our label element is now in the correct table cell. So once our form has labels added to all of the fields, it should be much more accessible to many more people. Another accessibility enhancement we can make is adding field set and legend elements. We'll do that next.

There are currently no FAQs about Web Accessibility Principles.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

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.

join now 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 Web Accessibility Principles.

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
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.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

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
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.