Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Examining basic table structure

From: Up and Running with HTML

Video: Examining basic table structure

In this chapter, we're going to focus on using tables in HTML. Tables are one of the most useful elements in all of HTML, as they allow us to represent data in something other than a linear fashion. Let's take a look at the basic syntax of a table. Now, to do that, I've opened up the tables.htm file, which you can find in the 05_01 folder, and I have opened it up in a browser. And that's because I sort of wanted to go over some of these tags before we start working on our sample table. So, our basic table structure is composed of really four basic tags, and you can find them right up here in this paragraph: a table tag which identifies to the browser that we're beginning a table, and then a table row, and that tr or table row tag establishes a new row every time it appears.

Examining basic table structure

In this chapter, we're going to focus on using tables in HTML. Tables are one of the most useful elements in all of HTML, as they allow us to represent data in something other than a linear fashion. Let's take a look at the basic syntax of a table. Now, to do that, I've opened up the tables.htm file, which you can find in the 05_01 folder, and I have opened it up in a browser. And that's because I sort of wanted to go over some of these tags before we start working on our sample table. So, our basic table structure is composed of really four basic tags, and you can find them right up here in this paragraph: a table tag which identifies to the browser that we're beginning a table, and then a table row, and that tr or table row tag establishes a new row every time it appears.

Inside your table rows you'll either have a table header or a table cell tags. Yes, I know it's td and the d stands for data, but most people will refer to that as a table cell tag. We have a table here. This is a sample HTML code, a little sample table that we're going to be building. Now the sample code we're looking at here is sort of the finished version of this. So throughout this chapter we're going to begin to build this table starting with the most simple basic table elements and then getting more complex as we keep adding more and more to the table. So, I'm going to switch over to my code editor and go into the same file that we had opened up in the browser.

This is tables.htm from 05_01. And we're going to start coding our table using these basic table elements. Now, you want to scroll down through the code. There is this little section right here, this preformatted section, that has this sample code in it. I've collapsed that so that I'm saving a little bit of screen real state. So if you're wondering why you don't see it on mine and you see on yours, that's why, you're going to scroll all the way down until you find this little comment that says, "create table here," and I'm just going to create an empty space or two to begin our table.

Now, as I mentioned before, the tables start with a table tag. So I'm going to begin by entering an opening table tag. And I like to go ahead and close my table out, so I'm going to go ahead and create a closing table tag as well, so just create a little bit of empty space in between that. Now again, this is a habit I like to get into for any complex structure. Once you start creating a table, a lot of times you're going to be working on that for a good twenty or thirty minutes. It's really easy to forget to close that table tag, so I like to close one as soon as I open one up, leave that space in between it empty, and just begin working.

Okay, so once you've created a table, you need to define its rows and columns. The rows are going to be defined by using a tr, or table row, tag, so that's the first thing I'm going to do is go ahead and create a table row tag. Now the other thing, I'm going to go right underneath that and once again I'm going to close this table row tag back out again. So we've just created the first row in the table. Now we need to start creating columns. Now, there is no table column tag. That does not exist; rather, columns are created by placing individual cells which represent each column.

So in the case of this particular table, we're going to have five rows and three cells, so inside this row we need to have three cells. The basic table cell tag is the td tag, so we're going to start with that. So I'm going to open up a td tag, and inside of that I'm just going to go ahead and put a nonbreaking space. You don't need to do this. It's just a habit that I have of just putting a little bit placeholder content in that table, data; it sort of holds the tag apart and lets me know that content is going to go there. If you want to leave them empty, be my guest.

And what I'm going to do is I need two more of those, so I'm just going to go ahead and do another td tag, another empty or another nonbreaking space I should say, and then close that td tag out, and one more. Now you're probably wondering, "hey, wouldn't it have been okay to just copy and paste that?" and you know what, you're absolutely right; it sure would be. So once you are satisfied with your syntax, that everything is correct and formatted the way you want it to, tables have a lot of repeating structures and there is absolutely nothing wrong with copying and pasting code.

But one of the things that you want to be careful about is that if you have an error in your syntax and then you copy and paste that error, you're compounding it. So you really, before you start copying and pasting things, you want to make sure that your syntax is right. So I'm going to copy this entire row, and like I said, we need five rows, so I'm going to go ahead and hit Return and paste that and I'll hit Return and paste it again. That gives me three, four, and finally five. All right! So I have got five tables rows and we have three columns in this table.

Now, if I save my file right now, go back into the browser and refresh this, if I scroll down, it doesn't look like we've done anything at all. Well, remember, this table is empty. But I do notice there is a good bit more space here. If I highlight the page I could begin to see the very, very beginnings of our table structure. We can see the three columns that are very thin. They don't have anything in them except that one little piece of whitespace. And then we have the five rows to our table. So really, with just those three elements-- the table tag, the table row tag, and the table cell tag--you can create basic tables.

Of course, as a table, it's not going to do you a whole lot of good unless you have some content inside of it, so we're going to look at adding content in our next exercise.

Show transcript

This video is part of

Image for Up and Running with HTML
Up and Running with HTML

49 video lessons · 27588 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 2m 12s
    1. Welcome
      55s
    2. Using the exercise files
      1m 17s
  2. 29m 30s
    1. Learning HTML
      2m 47s
    2. Choosing a code editor
      5m 2s
    3. Exploring basic HTML syntax
      8m 18s
    4. Do I need to learn HTML5?
      5m 6s
    5. Exploring HTML references
      8m 17s
  3. 35m 40s
    1. Exploring an HTML document
      5m 19s
    2. Working with doctype declarations
      4m 3s
    3. Examining the document head
      8m 20s
    4. Looking at the document body
      3m 21s
    5. Adding document structure
      8m 52s
    6. Lab: Coding a basic page
      3m 9s
    7. Solution: Coding a basic page
      2m 36s
  4. 1h 23m
    1. How does HTML format text?
      5m 51s
    2. Adding headings
      7m 24s
    3. Formatting paragraphs
      4m 54s
    4. Controlling line breaks
      3m 50s
    5. Creating lists
      10m 37s
    6. Emphasizing text
      6m 42s
    7. Displaying special characters
      5m 8s
    8. Controlling whitespace
      4m 35s
    9. Inserting images
      9m 20s
    10. Lab: Controlling page content
      13m 57s
    11. Solution: Controlling page content
      10m 55s
  5. 31m 54s
    1. Linking to pages within your site
      6m 45s
    2. Linking to external pages
      3m 2s
    3. Linking to downloadable resources
      2m 25s
    4. Linking to page regions
      8m 0s
    5. Lab: Creating Links
      5m 57s
    6. Solution: Creating Links
      5m 45s
  6. 40m 27s
    1. Examining basic table structure
      5m 10s
    2. Adding content to tables
      6m 20s
    3. Setting table attributes
      7m 42s
    4. Adding table captions
      4m 3s
    5. Defining table headers
      2m 13s
    6. Making table data accessible
      5m 46s
    7. Lab: Building tables
      4m 13s
    8. Solution: Building tables
      5m 0s
  7. 43m 23s
    1. Understanding the relationship between HTML and CSS
      4m 58s
    2. Creating inline styles
      4m 53s
    3. Exploring the style element
      5m 13s
    4. Basic font styling
      9m 24s
    5. Changing color
      4m 55s
    6. Taking styles further
      5m 24s
    7. Lab: Controlling basic styles
      5m 10s
    8. Solution: Controlling basic styles
      3m 26s
  8. 5m 44s
    1. Next steps
      2m 56s
    2. Additional resources
      2m 48s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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.


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 Already a member? Log in

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 Up and Running with HTML.

Return to your organization's learning portal to continue training, or close this page.


OK

Course retiring soon

Up and Running with HTML will be retired from the lynda.com library on October 31, 2014. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion. For updated training, check out HTML Essential Training in the lynda.com Online Training Library.


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 preferences from 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

Your file was successfully uploaded.

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.