Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
We'll close out our chapter on tables by creating a table that will act as a quick reference for comment named character entities. And of course this is going to be within our Up and Running with HTML Reference site. Let's take a quick look at the steps for our lab. To do that I'm going to open up reference.htm, which is going to be your lab file, here in the 05_07 folder. I've got, at the very top of the page, all these comments with their steps in it. So let's go through the steps just one by one. The first step is find the data for the table at the bottom of the page.
It's located in an HTML comment below the closing HTML tag. You're going to use this data to create a simple table with 3 columns and 18 rows. I'm going to scroll down and show you that data. When you scroll down you're probably going to look at your screen and you're going to look at my screen and you're going to say "wait a minute; this doesn't look the same." It's the same data, but depending upon which code editor you're using, you're not going to see this nice little three-column thing I have set up here.
They could be all over the place. You got the word wrapping going on. So I don't want you to freak out if you don't have a neat and tidy little columns like I do here. Feel free to just pause the video and take a look at this and then clean yours up a little bit. You may have to delete some spaces, you may have to reformat them, or you can just leave them the way they are, because essentially what's going on here is the first one will be the first table cell, then the second one will be the second table cell, third one will be the third table cell, and then you get a new row. The data is going to be all there; it just may not be formatted this way. Because this is just sort of a raw text file and because this is an HTML comment, there's really no way for me to guarantee that the spacing is going to be the same.
Now let me get back up to our other steps here. The next step is examine the data determine which cells should be table header cells. So that means look at the data and kind of figure out where your headers are going to be: Are they're going to be the top of the table or are they going to be on the side of the table? Which of these cells should be table header cells? The third thing you want to do is go ahead and set the cellpadding and the cellspacing for the table to 0. Go ahead and set the border to 1. The next thing you want to do with your table is you want to make the table a little bit more accessible.
You want to set the scope of the table headers, and remember the scope is going to be either row or column based upon where you've put the headers. And you want to give the table a summary. I'm not going to give you the text for the summary. This is the part of the lab exercise is you have to look at the table and kind of figure out, "how would I summarize this?" Just remember that the summary should reflect the purpose and the content of the table, and it could be little longer than the caption. Now, speaking of the caption, you do need to create a caption for the table. One of the things that I want you to consider is whether any existing page content can be incorporated into the table as a caption. Hint, hint: so if you scroll down on the page, you'll find where the table goes.
Now, again, if you're wondering, why does your code looks so much taller then mine? I've collapsed several of these sections so that I don't have to scroll through all this. It's just one of the benefits of using this particular code editor: I can collapse those sections. So about line 82, I've got little table goes here. And gee, is there anything right around where the table goes that might identify what is in that table? Maybe something to make a good caption. Step number 6. In the first table cell of each row give the table cell a class attribute. We haven't talked a lot about classes, but if you set an ID attribute you can set a class attribute. It's class, equals, and then whatever value you want to pass in. The value we want to give it is center, so class attribute of center for each one of these first table cells in each row.
For the most part, you're probably going to find building this table pretty straightforward. But you know, I'll honest with you: this is certainly more like what you're actually going face in the real world as you start building your tables. And it introduces a very real danger with tables: it's so easy to make a mistake when dealing with such repetitive code. It's table row after table row, after table cell, after table cell, so take care as you construct a table to make sure there aren't any errors in the table's syntax.
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.