Tutorial 9
Welcome to the next tutorial, this tutorial is on HTML tables, this will be a quick tutorial
NOTE for this turorial, i am replacing all < and > with { and } repaectively, this will alieviate the need to use
the code tags, and should make the tutorial easier to read, if you wish to use the code, remember that you
replace all the { with < and all the } with >
got it?
I would like to start off with the non breaking space.
Because you can have as much "white space" as described abive, in an html document, any place where there
is more than one 'space', meaning a space bar key, lol, so if you wanted to use more than one space, you
would have to use a non breaking space:
$nbsp;
yes, all six letters make up the non breaking space, another use of this space, it will NOT wrap in a page, and
therefor is useful to keep alignments and such
Ok, the reason for having a short tutorial on non breaking spaces is because an empty cell in a table (a cell is
ONE block, so for instance, block 3,4 third over fourth down), IF the table has borders, it does not display the
empty cell very well, so by adding a non breaking space to any enmpty cell, this problem is fixed, as it is no
longer empty, (an empty cell will not display borders, as for why, i have no clue)
To start the creation of a table, you use the table tag: {table}, this tells the browser that the table is
starting, you can add several modifiers to this tag, such as width and border. explained now
{table border="1" width="50%"}
The border tells the browser how many pixels wide the boder should be, you can use 0 (zero) to not display
table borders
The width can either be in % or PX the percentage tells the browser that the table should be 50% as wide as
the open browser window, where as the PX tells the browser it should be 50 pixels wide, no matter how wide
the window is, this can cause the table to go off the side of the screen in some instances
So now that we can tell the browser we have a table, how do we put data in it?
The main pieces of a table, are the Table Rows, and table Data, {tr} and {td} respectively
{tr} Tells the browser to add a new row
{td} tells the browser to add a new column in that row
Note that it is always good practice to close these tags after the data
So a simple table would look like this:
{table}
{tr}
{td}
Ryan
{/td}
{td}
Timmons
{/td}
{/tr}
{tr}
{td}
Mike
{/td}
{td}
Osborne
{/td}
{/tr}
{/table}
Which would display like:
we can add a border around a table by changing the table tag like this:
{table border="1"} where 1 is the width of the table
ok, so, now lets show this without all the whitespace, meaning, lets rewrite this code so that it takes up as litle
room as possible:
{table}{tr}{td}
Ryan
{/td}{td}
Timmons
{/td}{/tr}{tr}{td}
Mike
{/td}{td}
Osborne
{/td}{/tr}{/table}
This is about as small as we can make the code, and still keep it somewhat organized, it will display the same.
Ok, so now we can make a table, you can put pretty much any other html inside the table, including other
tables (that looks odd)
so for instance, we can put a link in:
{table}{tr}{td}
{a href="http://www.ryan.com"}Ryan{/a}
{/td}{td}
Timmons
{/td}{/tr}{tr}{td}
{a href="http://www.mike.com"}Mike{/a}
{/td}{td}
Osborne
{/td}{/tr}{/table}
you can add font, links, and anything else you really wish to add
Dont forget to close table tags, as seen above, Also remember that you do NOT need to include additions to
tags in the closing table tag..... example
YOU DO NOT NEED TO DO THIS:
{table border="0"}{tr}{td}
{a href="http://www.ryan.com"}Ryan{/a}
{/td}{td}
Timmons
{/td}{/tr}{tr}{td}
{a href="http://www.mike.com"}Mike{/a}
{/td}{td}
Osborne
{/td}{/tr}{/table border="0"}
the {/table border="0"} is just a waste of time, unless you copy and paste tags, then dont waste the time to
take it out, either way, how you organize code is up to you.
End Intro to Tables
Next Will be code organization