Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
>> In more complex tables, the header information for a given cell might not be in the same row or column as that cell or the cell might have more than two headers that apply to it. In these cases, you need to use the headers attribute instead of the scope attribute to associate the data cell with its header cells. You do this by assigning an ID to each of the header cells and then listing the IDs of the applicable header cells in the headers attribute of the TD tag. Let's view an example of this sort of example in government.html.
If you're following along with the exercise files, this page is located in the 07_05 folder of the chapter seven exercise files. Open it in Dreamweaver's design view. Scroll down the page past the meeting minutes table that we worked on earlier. A new table has been added to the page with the caption of comparison of adopted budget amounts and actual spending for transportation department 2004 to 2006. If we look at one of the numbers in the table, say this number 15 in the third row, we can see that it doesn't just have two heading cells.
The cell labeled dollars and millions is one of its heading cells, so is the cell labeled actual. But also the cell labeled 2006 - 2007 provides heading information for the number 15 in this cell. This is a case where TH cells and scope attributes of a row or column will not adequately describe how this cell is connected to the others around it. Sometimes these sorts of tables can be remade into a simpler form so that every data cell does only have one row heading to one column heading.
But there are many tables far more complicated and large than this example one that can be set up in a way that would give each cell only two header cells. This table already has some TH cells with scope set as you can see with the bold formatting that is applied to our TH cells. We want to keep the cells as TH cells and we want to keep the scope attributes, but we'll just add on to it from there. Let's look at the scope attributes for each of the cells under the fiscal year column. Click inside the first cell labeled 2006 - 2007.
Move down to the tag selector at the bottom of the document window and click on the TH tag. Now right click or control click on that tag and select quick tag editor. You can see the full HTML for this TH cell. We can see that it's standing three rows and that it has its scope set to row. However, this isn't correct. It's not just heading one row, but the entire group of three rows. So the value that we should use in the scope attribute is row group. Place your cursor after row in the scope attribute and add on the word group.
Now it's scope attribute more accurately describes what it is heading. There's also a scope attribute value of call group. It doesn't apply to this table, but that's also an option that you can use in your own tables. Let's make the same changes to the other fiscal year cells. Click in 2005 - 2006 then right click or control click on the TH tag in the selector and select quick tag editor. Type row group in the scope attribute. Then click on the 2004 - 2005 cell in the tag selector right click or control click on the TH tag and select quick tag editor.
Again, type row group in the scope attribute. Click outside the table. The next change we need to make is changing each of the items in the budget column to be table header cells as well. We can see that they are header cells by clicking in one of them and looking at the tag selector. The current tag is TD. The fact that their text is not bold is also a clue that they currently aren't set as TH tags. We'll use find and replace to quickly change all of these cells to TH cells with the scope attribute of row.
First go to the code view by clicking on the code button in the document tool bar. Select over the entire TD cell with the text adopted in it, including the opening TD tag, the text and its closing TD tag. Then go to the Edit menu and select find and replace. The HTML that was selected is automatically filled in the find field. We want to leave find in current document set and search source code set as well. With the text in the find field selected, hit control C or command C to copy and paste it into the replace field.
But then highlight over the D in the opening TD tag in the replace field and type H scope="row" then highlight over the D in the closing TD cell and type H. Uncheck the use regular expression box if it's currently checked. Now click on replace all. In the results panel, we can see that all three cells that had the text adopted in them have been changed to TH cells with a scope of row.
We'll repeat that for the remaining budget type cells. Go to the Edit menu and click on find and replace. Copy the text in the find field using control C or command C and paste it into the paste field using control V or command V. Change the text in the replace field to actual. Change the adopted text in the find field to actual as well and then highlight over all of the TH code, including the scope attribute and its value and type TD.
Also change the closing TH tag to a closing TD tag in the find field. Now click replace all. Finally, repeat this for the cells labeled different. Go to edit > find and replace, control C or command C to copy the text in the find field, control V or command V to paste the text into the replace field. Highlight over the text actual in the replace field and type difference.
Highlight over the text in the find field and also type difference. Then highlight over all of the TH code in the find field and type an opening TD tag and a closing TD tag then click replace all. So now we have all of the cells that are heading other cells correctly marked up as TH cells with their scope attributes set correctly as well. This gets the complex table closer to being fully accessible but we still haven't added the ID and headers attributes that I mentioned earlier.
We'll continue to improve this table in the next movie.
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.