Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

38
Tables Web Authoring

Transcript of Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Page 1: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Tables

Web Authoring

Page 2: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.
Page 3: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

This kind of a table

THIS Is a TABLE

THIS Is a TABLE

THIS Is a TABLE

THIS Is a TABLE

Page 4: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

html tables

Do you really want to create a table? Here’s the tag and attribute to use

<table> ......contents of table....... </table>

Page 5: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

html code

The <table> tag begins the table you place what you want inside, and end the table with the </table> tag. To begin adding contents to your table, you will need the <td> tag.

The "TD" stands for table data, which is what you will place after this tag. You end a table data section with the </td> tag.

Here is a basic table with just one cell: <table> <td> This is my table! </td> </table>

Let’s go type this into a new html document, save it as tables and see what we get!

Page 6: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

What? You want a border…

To get the border we just add the border command to the <table> tag, like this:

<table border="2"> <td> This is my table! </td> </table>

Go ahead try it! You can set the border to be as big or small as you like

by changing the number inside the quote marks. If you set it to border="0", you will have a table with no

border around it.

Page 7: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

More then one cell

Of course, you probably want the table to have more than one cell in it.

To add another cell on the same line, just use the <TD> tags again, like this:

<TABLE border="2"> <TD> This is a cell </TD> <TD> This is a cell </TD> </TABLE>

Try it and see what you get!

Please type

Your html code in lowercase!!

Page 8: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

How do I get…

More rows with cells on the next line? To do this, use the table row tags, <TR> and </TR>:

<TABLE border="2"> <TD> This is a cell </TD> <TD> This is a cell </TD>

<TR> <TD> This is the new row </TD> <TD> I'm on the new row, too! </TD> </TR> </TABLE>

Try it!

Please type

Your html code in lowercase!!

Page 9: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Everything is too close and bunched up There are a couple of commands you can add

to the <table> tag to get more spacing between cells. Here they are:

cellspacing=" “” Use this command to add more space around each

cell. Place a number inside the quote marks.

cellpadding=" “ Use this command to add more space inside each

cell. Place a number inside the quote marks.

Page 10: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Cellpadding and cellspacing in action <table border="2" cellspacing="12">

Add the above to your table in html What do you get? Now, remove the cellspacing Change the tag to include cellpadding, like this:

<table border="2" cellpadding="12">

What do you get?

Page 11: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Can I use both at the same time?

Of course! Type this in and check it out!

<table border="2" cellspacing="15" cellpadding="15">

Page 12: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

What about hyperlinks?

To use a link inside a cell, just place the link tag inside your <td> tags, like this:

<td> <a href="http://www.mainlandregional.net">

My Favorite Web Site!</a> </td>

Try it out!

Page 13: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

What about images?

To place an image inside a cell, you do the same thing with the image tag:

<td> <img src=“mrhs.jpg"> </td>

Try it! Remember …you must have the image already

saved to your h: drive And it must be in the same folder as the

website you are creating!

Page 14: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

What else?

What else can you add? You can add links, images, headings,

paragraphs and more . Just imagine

Page 15: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Assignment #1

Create a 3 row and 3 column table Save it as fruit.html List pieces of fruit in each cell

Do not duplicate any piece of fruit Let me see your work when you are

finished

Page 16: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Assignment #2

Open your fruit.html Under each row listing the fruit add another row Go to Google and save 9 pictures of each of the

fruit you listed yesterday Insert the images under the corresponding fruit Save it with the same name Make sure I see it when you are finished! Happy Halloween!

Page 17: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Table dimensions

to define the width of your table … add the width=" " command to your <TABLE> tag.

Place the number of pixels wide you would like the table to be between the quote marks.

So, if you wanted a table 600 pixels long, you would do this:

<TABLE width="600" border="2"> <TD> This table really long! </TD> </TABLE>

This table has just a little text, but stretches all the way to 600 pixels, because we told it to!

Page 18: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Alignment

What if you wanted your contents to be aligned to the center or to the right? To do this, you add the align=" " command to your <TD> tag. You can use the command three ways:

align="left"Aligns your cell contents to the left.

align="center"Aligns your contents to the center.

align="right"Aligns your cell contents to the right.

Page 19: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Let’s try it

<TABLE width="450" border="2" cellspacing="7" cellpadding="7"> <TD align="center"> I'm in the center! </TD> <TD align="right"> I'm aligned to the right! </TD> </TABLE>

Page 20: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

valign

You can also use another alignment command for your cells, the vertical alignment command.

It looks like this: valign=" " . Here's what it can do:

valign="top"Aligns contents to the top of the cell.

valign="middle"Aligins contents halfway between the top and

bottom of the cell.

valign="bottom"Aligns contents to the bottom of the cell.

Page 21: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Try it

Here is a sample table using the vertical alignment commands:

<TABLE width="550" border="2" cellspacing="7" cellpadding="0"> <TD align="center" valign="top"> I'm on top! <br>So I start on top! </TD> <TD align="center" valign="middle"> I'm in the middle </TD> <TD align="center" valign="bottom"> I start at the bottom. </TD> </TABLE>

Check it out in the browser…….

Page 22: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Some more about v. alignment

The vertical alignment commands only come in useful if your table cells don't have the same number of lines inside each cell.

If there are 2 lines of text in the first cell while the others had one line, the vertical alignment will make a difference in how the table looks. If I had only used one line of text in each cell, the vertical alignment commands wouldn't make any difference.

So, how about stretching out the rows and columns? Well, now you get two more commands for the <TD> tag, rowspan and colspan.

rowspan=" "Defines the number of vertical table rows the cell should take up. Place your number inside the quote marks.

colspan=" "Defines the number of horizontal columns the cell should take up.

Page 23: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

You want your table to look like this

Nice, right?

This too!

Page 24: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Just do it. . .

How many rows do you want? How many columns are there? Use the rowspan command in your table cell containing the image.

You set rowspan="2" and the cell with the picture takes up 2 table rows. Here is the code:

<TABLE border="2"> <TD align="center"> Nice, right?</TD> <TD rowspan="2" align="center"> <IMG SRC=“face.jpg"> </TD>

<TR> <TD align="center"> This too! </TD> </TR> </TABLE>

Page 25: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

What about this look?

Some text here Nav bar here

Page 26: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Just do it…

This time you use the colspan command and set colspan="3". You get the first cell to stretch across the other three on the second row below it.

Here is the table code for this:

<TABLE border="2" cellpadding="5"> <TD colspan="3" align="center"> <Banner here</B> </TD>

<TR> <TD align="center"> <img src=“face.jpg”> </TD> <TD align="center"> Some text here </TD> <TD align="center"> Nav bar here </TD> </TR> </TABLE>

Page 27: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

But…can we add color?

Yes, Toto…you’re not in Kansas anymore!

Color can be added to the text in a cell or to the actual cell itself

Page 28: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Here you go

This makes the entire table the same color

<TABLE border="5" bgcolor="red">

Now the whole table has a red background!

Page 29: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

To change the color or each cell… Add the bgcolor command to each <TD> tag

you want to change:

<TABLE width="75" border="2"> <TD bgcolor="red"> red </TD> <TD bgcolor="blue"> blue </TD> </TABLE>

Now the two cells are different colors

Page 30: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

To change the row color

Add the bgcolor command to the <TR> tag:

<TABLE width="200" border="2" > <TR bgcolor="red"> <TD> red </TD> <TD> red again... </TD> </TR> <TR bgcolor="blue"> <TD> blue </TD> <TD> blue again! </TD> </TR> </TABLE>

Page 31: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Assignment #3 Create a table that looks

like this: Save as tv.html Have the rows alternate

between two colors Make the text a color that

is easy to read List the names of the

following main characters for the TV show listed: House (last season) in

one row Friends in one row The Flinstones in one

row Family Guy in one row

TV Show Characters

All of the main characters may not fit….that’s ok! Some rows may be longer than others!

House characters

Friends characters

The Flintstones characters

Family Guy characters

Remember to re-size

your images!

Page 32: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

How about this crazy idea

Can I put a table inside of another tables?

Yes, it’s called a nested table!

Page 33: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Let’s try it

Make a new html document That means open your shell and save as:

Save it as nestedtable.html Let’s add the nested table tags…

Page 34: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

A nested table

<TABLE width="400" border="6"> <TD align="center">

<TABLE width="300" border="2"> <TD align="center">

I'm inside the small table!

</TD>

</TABLE> </TD> </TABLE>

Page 35: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

let’s try it

<TABLE width="400" border="6"> <TD align="center">

<TABLE width="300" border="2"> <TD align="center">

I'm inside the small table!

</TD> </TABLE> </TD> </TABLE>

Page 36: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

More nested tables

Nested tables can get a bit confusing at times. Try to keep track of which table you are in while

you are writing the code, those td tags get confusing.

Let’s try to have two tables side by side a, nested in one big table The border can be on the nested tables The border on the main (big) table can set to 0.

Page 37: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Nested tables

<TABLE width="600" border="0"> <TD align="center">       <TABLE width="275" border="4">       <TD align="center">       I'm in the first small table! Ha!       </TD>       </TABLE> </TD> </TD align="center">       <TABLE width="275" border="4">       <TD align="center">       I'm in the second small table! Ha, ha!       </TD>       </TABLE> </TD> </TABLE>

Page 38: Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.

Nested table assignment #4 In the table listing the words: I’m in the first

small table do the following: List all of the Brady Bunch main characters, name

only Each character should be in its own row and each

cell must be a different color In the table listing the words: I’m in the second

small table do the following: List all of the Gilligan’s Island main characters,

name only Each character should be in its own row and each

cell must be a different color Save this as nestedtable2.html