Basic HTML Formatting |
|
HTML Workshop, from ZDTV, original here.
|
Tip: The organization of your website is important. Create separate folders for each section as well as one for your graphics. |
Let's say you have a site devoted to ZDTV. Each show would have its own folder and you would most likely have an images folder as well.
Picture the letter Y. The bottom of the Y is the root directory and each arm represents a folder. One arm is the Call for Help folder and the other is the image folder. In order to reference an image from the Call for Help arm, you have to come down to the stem of the Y before you can reach the other arm. Likewise, you need to come out of the folder you are in to go into the folder you want.
The html code must reflect this. In order to reference that folder, you precede the folder and file name you are looking for with a ../. Each layer of folders can be accessed with an additional ../, so if you have to go up two directories, your code would look like this:
<IMG SRC="../../images/filename.gif">
An alternate method to reference this image would be to include the entire URL:
<IMG SRC="http://www.yoursite.com/images/filename.gif">
Alignment
The IMG tag can be aligned left, right, center, bottom, top, middle. This refers to the image in relation to other things on the page. If you only have an image and you set it to align=right, the image will appear on the right side of the page. If you place this tag in front of a paragraph, the image will appear to the right of the paragraph.
You can place the align attribute before or after the file name. Just be sure to separate it with a space:
<IMG SRC="filename.gif" ALIGN=LEFT>
You can also add a border to your image. Just as you add the align attribute, you would add BORDER=# (0-99) within the image tag. This places a black border of that width around your image. When an image is linked, it will have a border by default. To override this, add BORDER=0 to the IMG tag.
Image size
Add size attributes to your image to alert the browser to the layout of your page. Size is determined by HEIGHT and WIDTH, which are set to equal the pixel dimensions of your image:
<IMG SRC="filename.gif" WIDTH=50 HEIGHT=100>
Tip: You can tweak an image's size by changing the WIDTH and HEIGHT values. For example, if you create a red square that is only one pixel by one pixel, the file size will be small, but you can make the image as large as you want. Set the square's size to HEIGHT=1 and WIDTH=400. Voila-- an instant line.
Now that you've mastered adding images to your site, here is some sad news. Not everyone will be able to see your images. Some people browse the Internet with images turned off and some have text-only browsers. Some disabled people rely on software that can read the contents of a page to them. This software cannot read an image and the image titles are often not intuitive enough.
The ALT tag comes to the rescue. This attribute is placed within the IMG tag just as ALIGN and BORDER are. ALT="some text" will not only display the text in the place where the image loads, but will display the text when the mouse hovers over the image. This way, even though the image is not seen, a description is.
Once you have mastered the IMG tag, you're probably itching to make something happen. The next workshop is devoted to linking, but here is a snippet of code to quench your thirst:
<A HREF="file_to_link_to.html"><IMG SRC="image_you_want_linked.gif"></A>
The first HTML book I read looked as if it was written in a foreign language-- which it was. Imagine the thrill I felt when I made my first successful hyperlink. Previously I had taken websites for granted, assuming that anything I clicked on would magically deliver me to a new place. Now I knew what made links work. This new communication with my computer was equally as exciting as successfully ordering a meal in French.
I hope this lesson will spark the same excitement in you.
What to link
You can link any text or image on your site. This is achieved by surrounding the text, or the image tag, with an anchor tag.
Here are two sample tags:
<A HREF="page_to_link_to.html">Linked Text</A>
<A HREF="page_to_link_to.html"><IMG SRC="image_to_link.gif"></A>
What the code means
The first A in the anchor tag tells the browser that this will be a link. HREF tells the browser to reference a hyperlink-- or a clickable item. The destination of the link is placed between the quotes in the form of a URL. Your text, or image tag, follows and the link is completed with an ending anchor tag. You will notice that omitting the ending tag will cause everything following this link to be linked as well so don't forget it.
If you would like to know more about the image tag, read this article.
Proper code
URLs need to be written correctly for them to work. Many websites have levels of folders. That means your main page might point to a folder that houses your products. The images might live in another folder. Simply using the file name as the URL might not work if you need to link to a separate folder.
In order to reference a page in a folder other than the folder your document is in, add two periods and a forward slash (../) in front of the folder name, then add another slash and the file name you are referencing. Add a new ../ for each folder out of which you must climb.
<A HREF="../../pants/long_pants.html">Click here to look at some pants.</A>
If your site sells socks, you might have a folder called socks, then a folder within socks called blue_socks. If you want to link from a blue_sock page to a page in the pants folder, your code would look like this:
Each ../ takes you up a level, the /pants tells the browser to go into the folder called pants and choose the file name long_pants.html.
To avoid this confusion entirely, use the full URL: (http://www.yoursite.com/folder/page.html)
Linking within the same level does not require anything other than the file name.
If you would like to know how to change the color of your links, read this article on essential tags.
If your document is very long, you might want to create links within your page. Let's say you have a glossary. Instead of forcing your viewers to scroll through the alphabet, you can offer an A-to-Z list at the top of the page. Click on the letter Q and the browser would jump to the Qs. You can then add links every so often that, when clicked, will take the viewer back to the index at the top of the page.
The first step is to name the place in the page to which you wish to jump. Scroll to the place in your document that first mentions Quinelles. Then wrap the anchor tag around the Q as follows:
<A NAME="name_of_anchor">Q</A>
Now that the jumping point is named, you can refer to it from anywhere in your document. Go to the letter Q at the top of your document and add this tag:
<A HREF=#name_of_anchor>Q</A>
Now when the viewer clicks on the top letter Q, the paragraph about Quinelles will appear at the top of the screen.
If you would like to link to a specific spot on another page, follow the first step to name the spot on the other page. Then create a normal anchor link and add #name_of_spot to the end of the URL:
<A HREF="../pants/pants_page.html#name_of_spot">
You may have clicked on a link that takes you directly to your email program, or a browser email form. This is the mailto tag that also takes the form of an anchor link. Here is the format:
<A HREF="mailto:email_address"> Contact Us</A>
Substitute email_address with the address to which you wish to send mail. You can also specify the subject line of the email by adding ?subject= directly after the email address. This line,
<A HREF="mailto:bob@zdtv.com?subject=web workshop"> Contact Us</A>
would send an email to bob@zdtv.com with the subject line "web workshop."
This is intended to be a tutorial by example of Tables. This covers most of the new tags in tables, though it doesn't necessarily show some of the really creative capabilities available in tables.
A | B | C |
D | E | F |
<table border> <tr> <td>A</td> <td>B</td> <td>C</td> </tr> <tr> <td>D</td> <td>E</td> <td>F</td> </tr> </table>
Item 1 | Item 2 | Item 3 |
Item 4 | Item 5 |
<table border> <tr> <td>Item 1</td> <td rowspan=2>Item 2</td> <td>Item 3</td> </tr> <tr> <td>Item 4</td> <td>Item 5</td> </tr> </table>
Item 1 | Item 2 | Item 3 | Item 4 |
Item 5 | Item 6 | Item 7 |
<table border> <tr> <td rowspan=2>Item 1</td> <td>Item 2</td> <td>Item 3</td> <td>Item 4</td> </tr> <tr> <td>Item 5</td> <td>Item 6</td> <td>Item 7</td> </tr> </table>
Item 1 | Item 2 | |
Item 3 | Item 4 | Item 5 |
<table border> <tr> <td>Item 1</td> <td colspan=2>Item 2</td> </tr> <tr> <td>Item 3</td> <td>Item 4</td> <td>Item 5</td> </tr> </table>
Head1 | Head2 | Head3 |
---|---|---|
A | B | C |
D | E | F |
<table border> <tr> <th>Head1</th> <th>Head2</th> <th>Head3</th> </tr> <tr> <td>A</td> <td>B</td> <td>C</td> </tr> <tr> <td>D</td> <td>E</td> <td>F</td> </tr> </table>
Head1 | Head2 | ||
---|---|---|---|
A | B | C | D |
E | F | G | H |
<table border> <tr> <th colspan=2>Head1</th> <th colspan=2>Head2</th> </tr> <tr> <td>A</td> <td>B</td> <td>C</td> <td>D</td> </tr> <tr> <td>E</td> <td>F</td> <td>G</td> <td>H</td> </tr> </table>
Head1 | Head2 | ||
---|---|---|---|
Head 3 | Head 4 | Head 5 | Head 6 |
A | B | C | D |
E | F | G | H |
<table border> <tr> <th colspan=2>Head1</th> <th colspan=2>Head2</th> </tr> <tr> <th>Head 3</th> <th>Head 4</th> <th>Head 5</th> <th>Head 6</th> </tr> <tr> <td>A</td> <td>B</td> <td>C</td> <td>D</td> </tr> <tr> <td>E</td> <td>F</td> <td>G</td> <td>H</td> </tr> </table>
Head1 | Item 1 | Item 2 | Item 3 |
---|---|---|---|
Head2 | Item 4 | Item 5 | Item 6 |
Head3 | Item 7 | Item 8 | Item 9 |
<table border> <tr><th>Head1</th> <td>Item 1</td> <td>Item 2</td> <td>Item 3</td></tr> <tr><th>Head2</th> <td>Item 4</td> <td>Item 5</td> <td>Item 6</td></tr> <tr><th>Head3</th> <td>Item 7</td> <td>Item 8</td> <td>Item 9</td></tr> </table>
Head1 | Item 1 | Item 2 | Item 3 | Item 4 |
---|---|---|---|---|
Item 5 | Item 6 | Item 7 | Item 8 | |
Head2 | Item 9 | Item 10 | Item 3 | Item 11 |
<table border> <tr><th rowspan=2>Head1</th> <td>Item 1</td> <td>Item 2</td> <td>Item 3</td> <td>Item 4</td> </tr> <tr><td>Item 5</td> <td>Item 6</td> <td>Item 7</td> <td>Item 8</td> </tr> <tr><th>Head2</th> <td>Item 9</td> <td>Item 10</td> <td>Item 3</td> <td>Item 11</td> </tr> </table>
Average | |||
---|---|---|---|
Height | Weight | ||
Gender | Males | 1.9 | 0.003 |
Females | 1.7 | 0.002 |
<table border> <tr> <td><th rowspan=2></th> <th colspan=2>Average</th></td> </tr> <tr> <td><th>Height</th><th>Weight</th></td> </tr> <tr> <th rowspan=2>Gender</th> <th>Males</th><td>1.9</td><td>0.003</td> </tr> <tr> <th>Females</th><td>1.7</td><td>0.002</td> </tr> </table>
A | 1 | 2 |
3 | 4 | |
C | D |
<table border> <tr> <td align=center rowspan=2 colspan=2>A</td> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> <tr> <td align=center rowspan=2 colspan=2>C</td> <td align=center rowspan=2 colspan=2>D</td> </tr> <tr> </tr> </table>
Item 1 | Item 2 | Item 3 |
Item 4 | Item 5 |
<table> <tr> <td>Item 1</td> <td rowspan=2>Item 2</td> <td>Item 3</td> </tr> <tr> <td>Item 4</td> <td>Item 5</td> </tr> </table>
Item 1 | Item 2 |
Item 3 | Item 4 |
<table border=10> <tr> <td>Item 1</td> <td> Item 2</td> </tr> <tr> <td>Item 3</td> <td>Item 4</td> </tr> </table>
A | B | C |
D | E | F |
<table border cellpadding=10 cellspacing=0> <tr> <td>A</td> <td>B</td> <td>C</td> </tr> <tr> <td>D</td> <td>E</td> <td>F</td> </tr> </table>
A | B | C |
D | E | F |
<table border cellpadding=0 cellspacing=10> <tr> <td>A</td> <td>B</td> <td>C</td> </tr> <tr> <td>D</td> <td>E</td> <td>F</td> </tr> </table>
A | B | C |
D | E | F |
<table border cellpadding=10 cellspacing=10> <tr> <td>A</td> <td>B</td> <td>C</td> </tr> <tr> <td>D</td> <td>E</td> <td>F</td> </tr> </table>
A | B | C |
D | E | F |
<table border=5 cellpadding=10 cellspacing=10> <tr> <td>A</td> <td>B</td> <td>C</td> </tr> <tr> <td>D</td> <td>E</td> <td>F</td> </tr> </table>
January | February | March |
---|---|---|
This is cell 1 | Cell 2 | Another cell, cell 3 |
Cell 4 | and now this is cell 5 |
Cell 6 |
<table border> <tr> <th>January</th> <th>February</th> <th>March</th> </tr> <tr> <td>This is cell 1</td> <td>Cell 2</td> <td>Another cell,<br> cell 3</td> </tr> <tr> <td>Cell 4</td> <td>and now this<br>is cell 5</td> <td>Cell 6</td> </tr> </table>
can be applied to individual cells or whole rows
January | February | March |
---|---|---|
all aligned center | Cell 2 | Another cell, cell 3 |
aligned right | aligned to center | default, aligned left |
<table border> <tr> <th>January</th> <th>February</th> <th>March</th> </tr> <tr align=center> <td>all aligned center</td> <td>Cell 2</td> <td>Another cell,<br> cell 3</td> </tr> <tr> <td align=right>aligned right</td> <td align=center>aligned to center</td> <td>default,<br>aligned left</td> </tr> </table>
can be applied to individual cells or whole rows
January | February | March |
---|---|---|
all aligned to top | and now this is cell 2 |
Cell 3 |
aligned to the top | aligned to the bottom | default alignment, center |
<table border> <tr> <th>January</th> <th>February</th> <th>March</th> </tr> <tr valign=top> <td>all aligned to top</td> <td>and now this<br>is cell 2</td> <td>Cell 3</td> </tr> <tr> <td valign=top>aligned to the top</td> <td valign=bottom>aligned to the bottom</td> <td>default alignment,<br>center</td> </tr> </table>
January | February | March |
---|---|---|
This is cell 1 | Cell 2 | Another cell, cell 3 |
<table border> <caption align=top>A top caption</caption> <tr> <th>January</th> <th>February</th> <th>March</th> </tr> <tr> <td>This is cell 1</td> <td>Cell 2</td> <td>Another cell,<br> cell 3</td> </tr> </table>
January | February | March |
---|---|---|
This is cell 1 | Cell 2 | Another cell, cell 3 |
<table border> <caption align=bottom>A bottom caption</caption> <tr> <th>January</th> <th>February</th> <th>March</th> </tr> <tr> <td>This is cell 1</td> <td>Cell 2</td> <td>Another cell,<br> cell 3</td> </tr> </table>
1 | 2 | 3
|
||||
4 | 5 | 6 |
<table border> <tr> <!-- row 1, table 1 --> <td>1</td> <td>2</td> <td>3 <table border> <tr> <!-- row 1, table 2 --> <td>A</td> <td>B</td> </tr> <tr> <!-- row 2, table 2 --> <td>C</td> <td>D</td> </tr> </table> </td> </tr> <tr> <!-- row 2, table 1 --> <td>4</td> <td>5</td> <td>6</td> </tr> </table>
Width=50% | Width=50% |
3 | 4 |
<table border width="50%"> <tr><td>Width=50%</td><td>Width=50%</td> </tr> <tr><td>3</td><td>4</td> </tr> </table>
Item width affects cell size | 2 |
3 | 4 |
<table border width="50%"> <tr><td>Item width affects cell size</td><td>2</td> </tr> <tr><td>3</td><td>4</td> </tr> </table>
width=100% | This is item 2 |
3 | 4 |
<table border width="100%"> <tr><td>width=100%</td><td>This is item 2</td> </tr> <tr><td>3</td><td>4</td> </tr> </table>
A | B | C |
D | E | F |
<center> <table border width="50%"> <tr> <td>A</td> <td>B</td> <td>C</td> </tr> <tr> <td>D</td> <td>E</td> <td>F</td> </tr> </table> </center>
Item 1 | Item 2 | ||
|
Item 4 |
<table border width="50%"> <tr><td>Item 1</td><td>Item 2</td> </tr> <tr><td> <table border width=100%> <tr><td>Item A</td><td>Item B</td> </tr> </table> </td> <td>Item 4</td> </tr> </table>
height=5% | Item 2 |
3 | 4 |
<table border width="50%" height="15%"> <tr><td>height=5%</td> <td>Item 2</td> </tr> <tr><td>3</td><td>4</td> </tr> </table>
Copyright © 1995 Hagan Heller. The information on these pages may be freely copied, so long as they are not sold and this copyright information is included.