![]() |
![]() |
|
Free HTML TutorialHome >> Building Your Website >> Free HTML Tutorial
Download This Tutorial to Your PC
HTML Tutorial Index
|
|
Easy Web
Design -
No HTML
Needed |
Understanding tables, in my opinion, is one of the important lessons you can learn. Tables are such a fundamental part of web page layouts, and you can do so much with your page design if you understand how they work.
If you see a web page with a left navigation, usually that page is created by using one big table with two columns and no border. The left column is generally set to a smaller amount than the right column, thus setting up the left navigation.
The three most important tags for tables is the opening table tag, <table> and the table row and table data tags - <tr> and <td> respectively.
The <tr> tag represents a row for the table
The <td> tag represents a cell inside the row.
Now, with that in mind, let's create a simple table:
<table>
<tr> <td>A</td> <td>B</td> <td>C</td> </tr>
<tr> <td>X</td> <td>Y</td> <td>Z</td> </tr>
</table>
And this is what the table would look like published:
| A | B | C |
| X | Y | Z |
Notice that by looking at the code, you can tell how many rows and columns are included just by looking at the code. The two opening <tr> tags indicate two rows and the three opening <td> tags on each line represents three data cells (or three columns).
Adding a border simply involves inserting the border attribute to the opening table tag. So in the above table the code would be adjusted accordingly:
<table border="2">
<tr><td>A</td> <td>B</td> <td>C</td> </tr>
<tr><td>X</td> <td>Y</td> <td>Z</td> </tr>
</table>
Notice the "2" represents the thickness of the border. If you had set it to "0" then there would have been no border at all. If you wanted it very thick then you could set it to 8, for example. So now your table will look like this:
| A | B | C |
| X | Y | Z |
You can change the color of a table border by simply adding the bordercolor attribute.
<table border="2" bordercolor="red">
<tr><td>A</td> <td>B</td> <td>C</td> </tr>
<tr><td>X</td> <td>Y</td> <td>Z</td> </tr>
</table>
And here's what it would look like...
| A | B | C |
| X | Y | Z |
You can increase the space within the table cells and the space between the cells by using the cellpadding and cellspacing attributes.
The cellspacing attribute adjusts the space between the cells and cellpadding adjusts the space within (around) the cell.
<table border="2" cellspacing="10" cellpadding="3">
<tr><td>A</td> <td>B</td> <td>C</td> </tr>
<tr><td>X</td> <td>Y</td> <td>Z</td> </tr>
</table>
This is what the table would look like now...
| A | B | C |
| X | Y | Z |
See how setting the cellspacing attribute to "10" drastically increased the spacing between the cells, and the cellpadding attribute set to "3" added a little of space within each individual cell.
You can specify the width of a table by using either a percentage or a pixel width.
<table width="100%" border="2">
<tr><td>A</td> <td>B</td> <td>C</td> </tr>
<tr><td>X</td> <td>Y</td> <td>Z</td> </tr>
</table>
Since the width is set to 100% that means the table will take up 100% of the screen and the columns in the table will be adjusted evenly. Here's what it would look like.
| A | B | C |
| X | Y | Z |
As we mentioned, you can also set the table width using pixels instead of percentages. So instead of setting it to 100%, you could set it to 300 pixels:
<table width="300" border="2">
<tr><td>A</td> <td>B</td> <td>C</td> </tr>
<tr><td>X</td> <td>Y</td> <td>Z</td> </tr>
</table>
The table would look like this:
| A | B | C |
| X | Y | Z |
Sometimes you may not always want your columns to be the same size. If this is the case, you need to set values on your table data <td> cells. Again, you can set them by using percentages or pixel widths.
<table width="300" border="2">
<tr> <td width="70%"> A</td> <td>B</td> <td>C</td> </tr>
<tr> <td width="70%"> X</td> <td>Y</td> <td>Z</td> </tr>
</table>
This is what this
table would look
like.
| A | B | C |
| X | Y | Z |
See how the column width for the first column in both rows is set to 70%. Notice there is no value set for the other 2 columns. If you do not set a value for the remaining columns, their width will automatically be adjusted to take up the remaining space and they'll share it equally.
Since the table width is set to 300 pixels, and the first column is instructed to take up 70% of those 300 pixels (roughly 210 pixels), the other 2 columns divide the remaining 30% of the table (roughly 45 pixels a piece).
You could also have expressed the column widths of this table in pixels instead of percentages. The code would have looked like this:
<table width="300" border="2">
<tr>< td width="210" >A</td> < td width="45" >B</td> < td width="45" >C</td> </tr>
<tr>< td width="210" >A</td> < td width="45" >B</td> < td width="45" >C</td> </tr>
</table>
| A | B | C |
| A | B | C |
See how the width of the columns in each row add up to 300 (210 + 45 + 45) -- which is the width of the table.
Many people prefer to express their table width and column widths in percentages because that will ensure that the table takes up the same amount of screen no matter how big or small the screen resolution is.
If someone is using a 21 inch monitor to view your site and you have a table width set to 300 pixels, the table will show up very small on their screen. However if you set the table width to 70%, it will take up 70% of the screen no matter what size the person is using.
So it's really up to you to decide what's the best layout for your tables.
You can also set the table height by adding the height tag to the table code.
<table height="250" width="300" border="2">
<tr><td width="210">A</td> <td width="45">B</td> <td width="45">C</td> </tr>
<tr><td width="210">A</td> <td width="45">B</td> <td width="45">C</td></tr>
</table>
Which will produce the following table:
| A | B | C |
| A | B | C |
The content inside a cell is left aligned by default, but you can also center or right align the text as well by using the align attributes.
<table width="300" border="2">
<tr><td width="210" align="center" >A</td> <td width="45">B</td> <td width="45">C</td> </tr>
<tr><td width="210" align="center" >A</td> <td width="45">B</td> <td width="45">C</td></tr>
</table>
| A | B | C |
| A | B | C |
See how the first column is aligned to the center? You can also right align the columns by using the align="right" inside the <td> cells.
So far we've kept the table cell alignment at the default, which is the middle. Notice in the above table that the A, B, and C are all three aligned in the middle of their cells. Well you can change their alignment to either top, bottom, or middle by using the valign (which stands for vertical align) tag:
<table height="250" width="300" border="2">
<tr><td valign="top" width="210">A</td> <td width="45">B</td> <td width="45">C</td> </tr>
<tr><td valign="top" width="210">A</td> <td width="45">B</td> <td width="45">C</td></tr>
</table>
| A | B | C |
| A | B | C |
I've set the table height to "250" so the alignment would be more noticeable. Notice that the A in both rows are aligned to the top. You can also align to the "bottom" or the "middle".
As we mentioned earlier, most left and right navigations are created using tables. All you do is create a table with one row, two columns and no border. Then align both of your columns to the top (using the valign tag) so your text will start in the top of the columns, not the middle. Depending on if you're going to have a right or left navigation, you'll make one column significantly smaller than the other.
Here's a simple left navigation layout:
<table width="100%" border="0">
<tr><td valign="top" width=" 25% ">Left Nav Links Here</td> <td valign="top" width=" 75% ">Body Here</td> </tr>
</table>
And here's what it would look like:
| Left Nav Links Here | Body Here |
Notice I set the border to "0" but it's still showing in the example. I just did that to show how the layout would look. If you set your border to "0" you won't see any lines around your table.
So there ya have it! That's a general overview of tables. There's so much more you can do with them, but if you can understand the basic layout, you'll be able to do so much with the design of your web site.
Don't forget to try the auto HTML table generator !
Return to Index | Download Tutorial | Free HTML Editor
Once you have the image you want to use you can insert it into your web page.
Next you’ll need to do is upload the graphic to your web server. Your web hoster will either provide the environment for you to upload your images or you'll have to use an FTP program.
If you need help with FTP, click here.
When you upload the graphic, make sure you pay attention to what folder you’re putting it into because that will affect how you write the HTML.
Let’s say you upload the graphic called "apple.gif" to your "images" folder on your web server. The image folder is located inside your "root" directory.
Your HTML code will look like this:
<img src="images/apple.gif">
Now let’s say you have uploaded the graphic to the "fruit" folder/directory that is located inside of the images folder then the code would appear as:
<img src="images/fruit/apple.gif">
If you want text to pop up when you run the mouse over the graphic, then you need to add the alt tag.
<img src="images/apple.gif" alt="This is my apple">
If you want to adjust the height and width of the image then you need to use the height and width tags:
<img src="images/apple.gif" alt="This is my apple" height="100" width="150">
It is recommended that you always include the height and width of your images because it makes your pages load faster.
To add a border to your image need the "border" attribute. It’s very simple:
<img src="images/apple.gif" border="5"> The 5 represents the thickness of the border. The higher the number, the thicker the border. The number 0 is equivalent to no border. Or you could just leave the border attribute out if you do not want one.
Let’s say you want your graphic to have a border of 2, be 100 x 250 pixels (height x width) and have an alt tag:
<img src="images/apple.gif border="5" height="100" width="250" alt="This is my apple">
Please note that it does not matter what order you put the attributes in (border, alt, etc.). Just make sure you do not leave out any of the punctuation.
"Help, My Graphic Won’t Show!"
If your graphic does not show up and you receive the "broken image" icon, check the following:
Linking images is helpful if you have buttons or banners on your site and you want the visitor to be taken to another web page or site when they click on the image. To accomplish this, use the following code:
<a href="http://www.the_linked_site.com"><img src="images/apple.gif" border="0"></a>
The first part of the code tells the browser which site to go to and the second part, of course, tells it where the image is located.
Return to Index | Download Tutorial | Free HTML Editor
If used properly, backgrounds can really enhance your site. If used incorrectly, they can make your site very difficult to read.
If you plan to use a "loud" background that you think is cool, be sure to keep your visitors in mind. Even though you may love it, it may be distracting for the average visitor and you certainly do not want a background that takes away from your text.
In general, try to use light backgrounds on dark text.
To insert a background color on your web page, use the following code INSIDE your <body> tag:
<body bgcolor="red" >
You can specify any color, or you can use a hex value .
If you want an image for your background then you would use the background and image tag together:
<body background="images/weave.gif">
Keeping in mind that "images/weave.gif" is the location of the graphic. So you’re telling the browser that the graphic is located in your images folder off the root/main directory. You can also use the absolute path to your image. For example, http://www.yourdomain.com/images/weave.gif
Return to Index | Download Tutorial | Free HTML Editor
Hex values are used for generating colors other than the standard reds, blues, greens, yellows, purples, etc. As you learned above, to specify a purple font you just use the tag <font color="purple">.
But HTML doesn't understand colors like "sky blue" or "pea green" so if you want these kinds of colors, you need to specify a hex color value.
The hex color code chart below will give you the HTML code you need for your desired colors...
1. Drag the bar on the "Hue" selector to generate the desired base color.
2. Next double click inside the Brightness/Saturation grid to activate the cursor. Drag it until the desired brightness is achieved.
The "Swatch" bar shows you the final color result.
3. The Hex Color Code is generated at the bottom of the grid. Simply copy and paste the code into your page.
Return to Index | Download Tutorial | Free HTML Editor
You can insert bullets into your pages by simply using the <ul> (unordered list) and <li> (list item) codes.
<ul>
<li> Bullet 1 </li>
<li> Bullet 2 </li>
<li>Bullet 3 </li>
</ul>
The above code will create the standard, round bullet that looks like this:
If you would like an open-circle bullet, you can change the code slightly by adding an attribute to the <ul> tag. See below:
<ul type="circle" >
<li> Bullet 1 </li>
<li> Bullet 2 </li>
<li> Bullet 3 </li>
</ul>
This will create an open-circle bullet. See below:
Return to Index | Download Tutorial | Free HTML Editor
To indent your text about an inch to the right, simply use the open and closing <blockquote> tag around the text you want to indent.
<blockquote> This text will be indented indented </blockquote>
See how the code makes the text in the paragraph below behave:
sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text sample text
This text will be indented indentedReturn to Index | Download Tutorial | Free HTML Editor
| Code | Symbol |
Description |
| ™ | ™ | Trademark |
| & | & | Ampersand |
| ® | ® | Registered trademark |
| © | © | Copyright |
| † | † | Dagger |
| » | » | Right pointing double angle quotation mark |
| « | « | Left pointing double angle quotation mark |
| — | — | Em-dash |
| ° | 30° | Degree |
| ¼ | ¼ | Quarter |
| ½ | ½ | Half |
| ¾ | ¾ | Three quarters |
| · | · | Middle dot |
| ¡ | ¡ | Inverted exclamation mark |
Return to Index | Download Tutorial | Free HTML Editor
Horizontal lines are great for breaking up paragraphs of text or separating sections of your page.
To create the standard/default horizontal line, you'll just simply insert the <hr> code. This will create a line that looks like this:
To set the width of
your line, simply
add a "width"
attribute. For
example,
<hr width="250">
will create a line
that is 250 pixels
wide. See below...
You can also set the size of the line by inserting a value. So if you wanted a line that is 250 pixels wide and 6 pixels thick, you'd use the following code:
<hr width="250" size="6">
This will produce the line below:
Lastly, you can control the color of the line by inserting the color attribute:
<hr width="250" size="6" color="blue">
You may also use hex colors to define the color of the line.
Return to Index | Download Tutorial | Free HTML Editor
If you are not sure about this, contact your web hoster.
Next, download the formmail script and follow the instructions provided. Once you've edited the script as necessary, upload/save it to your site's cgi bin folder on your web server. If you do not have a folder named "cgi bin", then you can create a new folder/directory.
Then change the permission of the file to 755 (CHMOD 755). If you need help with uploading and changing permissions see the WSFTP tutorial .
Once the FormMail file is in place on your server, all you have to do is create a page with the form code to make it work.
Below you'll find the code for creating a form in which your visitors can fill out and the results will be emailed to your email address.
The form has the following fields:
Here is what the form will look like and below you will find the HTML code. You will need to change some variables (in red) to customize it to your own needs.
Here's the code for the form you can copy and paste. Feel free to remove the HTML code for fields you don't need or adjust the various values to fit your liking.
Notice the red text. This is what you need to edit to customize the form.
1) The 1st line
should be changed to
the address of the
FormMail script on
your server.
2) The 2nd line
should be the
address of the page
the user views after
they submit the
form. You may need
to create this page.
3) The 3rd line is
the email address
the form results
will be sent to.
4) The 4th line is
the subject of the
email when the form
is sent to your
address.
<form METHOD=POST
ACTION="http://www.yoursite.com/cgi-bin/formmail.cgi">
<input type=hidden
name="redirect"
value="http://www.yoursite.com/thankyou.html">
<input type="hidden"
name="recipient"
value="email@youremail.com">
<input type="hidden"
name="subject"
value="Form
Subject">
<p>Your Name: <input
TYPE="text"
NAME="Name"
SIZE="40"
MAXLENGTH="40">
</p>
<p>Password:
<input
TYPE="password"
NAME="password"
SIZE="10"
MAXLENGTH="10">
</p>
<p>Please Place me
on your mailing
list:
<input
TYPE="checkbox"
NAME="mailing-list"
VALUE="Yes" checked>
</p>
<p>What's Your
Gender?
<select
NAME="Gender">
<option
VALUE="Male">Male
<option
VALUE="Female">Female
</select>
</p>
<p>How Old Are You?
<input TYPE="radio"
NAME="Age"
VALUE="0-25"
checked>0-25
<input TYPE="radio"
NAME="Age"
VALUE="26-50">26-50
<input TYPE="radio"
NAME="Age" VALUE="50
and over">51 and
Over
</p>
<p>Comments: <br>
<textarea
NAME="comments"
ROWS="10" COLS="50"
wrap="virtual">
You can insert
default text here if
you wish
</textarea>
</p>
<p>
<input TYPE="submit"
NAME="Request"
VALUE="Submit This
Form">
<input TYPE="reset"
NAME="Clear"
VALUE="Clear Form">
</p>
</form>
Return to Index | Download Tutorial | Free HTML Editor
You can create a drop down navigation menu by using the code below. Simply copy the code into a text editor and edit the links accordingly.
When you're done, the drop down menu will look something like this:
Return to Index | Download Tutorial | Free HTML Editor
If you need help with designing your site, try Website Tonight Hosting. Choose from hundreds of HTML templates. Click here for details .
Free
HTML templates
Web hosts that provide free web software
Want to create a site like MySpace?
HTML table
generator
HTML table tutorial
FREE! FREE! FREE!
With every domain you register at
WebsitePalace.com, you receive the following for free...
- 70 Web Templates
- Quick Blogcast
- Starter Page
- Domain Forwarding
- e-Book Software
- Complete E-mail
- Online Photo Filer
Copyright 2002 - 2008 - 2CreateAWebSite.com - All Rights Reserved
Site Designed With Dreamweaver.
Advertise | 2 Create a Website Blog | Webmaster Forums | Privacy Policy