Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
When building items such as forms, it's often easy to forget specific accessibility or web standard conventions as you create your pages. Dreamweaver makes it easy to ensure that your pages are standards compliant by enabling its accessibility preferences. While exploring Dreamweaver's form accessibility preferences we will be introduced to another important tag in making your form elements fully accessible, the label tag. The label tag is used to associate a textual label with a specific form element. There are two ways to pass this association to the browser or any other devices consuming your content. The first is to wrap both the label text and the form element inside the label tag.
The second method is to use the for attribute in the label tag to reference a form element ID. The for attribute method is more flexible since it allows form elements and the labels to be physically separated, but still functional. So we will take a look at both methods once we turn on the accessibility attributes in Dreamweaver. To review Dreamweaver's accessibility of preferences we will need to go to the Preferences dialog box and on the PC you will find that under Edit > Preferences. On the Mac we will go to Dreamweaver and choose Preferences. So it brings up our Preferences dialog box and the second category from the top is Accessibility. So that's what I am going to choose. They are all in alphabetical order except for general, which is kind of at the top of everything. But you can see that our Accessibility Preferences really aren't that complex. We have accessibility options that we can turn on for our Form objects, for Frames, for Media, and for Images.
Now the default for these is to be turned on. So really you shouldn't even have to turn them on, but if you don't see what we are about to see as we insert form elements on the page, you need to go check those again and make sure the checkbox for Form objects is selected. Some people turn them off because every time you try to insert an image or a form object on the page, Dreamweaver is going to display a dialog box that asks some questions about making that particular object accessible. I don't recommend turning them off, because it actually speeds workflow process instead of impede it and you will see that in just a moment.
Well, let's go ahead and use a label tag. Go ahead and highlight both the word Name and the input text field. Once again use your Quick Tag Editor to wrap that in a label tag and that's all there is to it. Now there is a label tag around both the text and the text input form element. So if I switch back to Design View, nothing looks different. Now this form element is standards compliant and accessible. So we mentioned earlier that there are two methods of applying the label tag. Let's take a look at the second one. Click directly after your first input text field and hit Return to go down to the next line. We are going to place a request for an email address here. So we are going to use our Form objects in the Insert toolbar. So go up to your Insert toolbar and click on the Form tab and you are going to see it displayed all of the different form objects.
Now in CS3 there are some new icons over here on the far right-hand side. We have a chapter dealing with the Spry framework, but these four icons deal with doing Spry Validation. Now we are going to talk about validation in the later exercise and we will discuss these icons then. So I need to insert another text field. So I can find the Text Field on the far left-hand side, second icon from the left. Just go ahead and click that. Before it will ever place a text input element on the page, it brings up the Input Tag Accessibility Attributes and we have to answer a few questions here. Now we could click Cancel or we could click OK and it would go ahead and still put the element on the page, but it's a good idea for us to go ahead and fill out everything here, because that saves us a lot of steps. Our id is going to be "email", all lowercase, and for label, I am actually going to type in email: and that's going to be the physical text that's on the page next to it.
Notice that below that I have a style and it's basically asking me how I want to associate the label tag with the form element, should I wrap it with the label tag, should I attach it using the for attribute or should I just have no label tag whatsoever. Well, let's go ahead and attach the label with the for attribute in it. And if you are going to do that, it's very important that you go ahead and assign an ID at the top of it, because if you don't, then this method won't work. We can also choose to position it before the form item or after the form item. For further accessibility we can give it an access key and we can also specify a tab index order at this point. Tab index values can specify the order in which your form elements are tabbed through as somebody is filling out your form.
So I will just go ahead and click OK and right there on the page, it says now email and there is my form field right beside that. So notice that it actually saved me a step. I didn't have to type in the text Email, because it did that for me with a label tag. Now let's go in a Code View and examine exactly what's taken place here. So if we look at the code, now we have label tag with a for attribute and this is for Email and it wraps the text Email and then the label tag closes. So it's not wrapping the entire text and form element like our prior label tag.
This one is detached from it, but it's associated with it by using the for attribute and it's referencing the IDs. So these guys could be in separate table cells, they could be in different locations and they are still going to refer to each other. Screen readers will still be able to do direct, a correlation between the text and the form element and it's a lot more flexible in terms of a method. So we are actually going to convert our top example to using the for attribute as well. So I am going to go up into the label tag right above Name and I am going to type in for and the id of that text element is Name, so I will pass that along with it. And then I've got to remember to move the closing label tag. I could leave it where it is, but it's a better idea to go ahead and make everything consistent. So we will just move that closing label tag by highlighting it and dragging it just after the text name. Let's go ahead and save our file. And we will switch back over the Design View. So visually again, it doesn't look like a whole lot has changed there.
So making sure that Dreamweaver's accessibility attributes are turned on, makes creating standards compliant forms easier and a lot faster since it creates properly formatted labeled text at the same time that you place your form elements on the page. Next, we will use CSS to layout form elements without resorting to non-semantic table markup for our design.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.
Your file was successfully uploaded.