Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
>> Most forms contain some fields that must be filled out in order for the form to be submitted. It's important to notify your users of which fields are required before they fill out the fields so that they can do so correctly. And of course you need to make sure this essential information is provided to people with disabilities as well, so make sure that you avoid using colors to indicated fields that are required versus fields that are not.
Remember that not everyone is able to distinguish color. People can also change the settings in their browsers to change the colors you have set. And of course screen reader users will not be able to see the color. This means you should also avoid other visual formatting such as bold. This probably has a greater chance of being understood by sighted users but it's still not accessible to visually impaired and blind users. They need to have something in the HTML that can be conveyed to them. Another important consideration when indicating required fields is that you want to notify your users of the requirement before they get to the field.
Remember that a screen reader will be reading things in order and also, people using screen magnifiers are only seeing a very small portion of the screen at a time. If you place the indication of the required field after the field itself, users of these devices will probably already have skipped past the field and may never see the required filed indication. An asterisk is frequently used to denote required fields in a form. This has become so frequently used that it's basically a web convention now and is rather well understood even by screen reader users, so it's okay to use an asterisk, but make sure that you still notify all users about what the symbol means.
Something to keep in mind, though, when using an asterisk is that it's a very small character and may be hard for visually impaired users to see. If you can design your form so that the actual word required could be listed with every field, that's the most accessible option. If you're following along with the exercise files open the page departments.html in Dreamweaver. It's located in the 08_07 folder of the chapter eight exercise files. Let's mark some of the fields in this form as required.
We'll use an asterisk to do so. So first, we'll put a message explaining this in the paragraph that precedes the form. Place your cursor at the end of the paragraph text and type required fields are indicated by an then type *. Let's markup this entire sentence with strong text because it's important information that we want to emphasize. Open the properties inspector if it's not already open and click on the B button.
We can see in the tag selector that this applied strong text to our text. Now scroll down the page, place your cursor at the end of the name label text and type in an asterisk. Highlight over this asterisk as well and click on the view tag in the properties inspector. It's important that the asterisks be placed inside of the label element. This is because many screen readers have a special way of moving through forms known as forms reading mode. In this mode, the user can quickly jump from field to field filling out the information.
When in this mode, the only text that is read to the user are the text of the legend and label elements. If you place text outside of the labels or legends in your form, there's a chance that a screen reader user will never heard it. So keep the indication of which fields are required inside the label. W can see in the tag selector that the strong tag is inside of the label tag, which is listed to its left to show that it's the parent element. What if we wanted to provide even more explicit text about which fields are required to screen reader users who may not understand what the asterisk means? We can again use the off left positioning method to create text that will be read by screen readers but will not be seen by sighed users.
Click on the code button in the document tool bar to go into code view. Place your cursor after the asterisk that we just typed then type an opening span tab, a space, and in the menu of attributes that appears, double click on class. The class attribute is added and now we have a new menu showing the available classes. Double click on the off left class then move your cursor outside of the closing quotation marks and type the closing bracket for the opening tag of the span.
Now we can type the text required. Now type the closing span tag. When you type the first bracket and slash, Dreamweaver finishes the rest of the closing tag for you. Click on the design button in the document tool bar. You'll see that Dreamweaver is showing the text required on the screen. But remember that Dreamweaver is not an actual browser, it doesn't always show things exactly as they will appear in a real browser, so let's click on the globe icon in the document toolbar to bring up the preview in browser window and choose preview in Firefox.
We're asked to save the page, so click yes. We can see that in the browser only the asterisk is displayed. The rest of the text that says required is not on the screen. So this is an instance where the display in Dreamweaver is not completely accurate. Nevertheless our technique has worked. Although the asterisk is colored red, we're not indicating that the form is required by color alone, we're indicating it with a symbol that we've explained. The color is just an example of progressive enhancement.
There's still something there in the HTML, in this case a symbol, marked up with a strong element and also containing the text required for screen readers. The important thing to remember is that required fields need to be indicated through something in the HTML, not through visual formatting alone.
Get unlimited access to all courses for just $25/month.Become a member
58 Video lessons · 59303 Viewers
61 Video lessons · 92241 Viewers
82 Video lessons · 104072 Viewers
56 Video lessons · 106806 Viewers
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.