QUICK TUTORIAL - HTML ATTRIBUTES: CUSTOMIZING THE TAGSTags really begin to be useful when you start adding attributes and values to them. All of the other things that show up in a tag besides the tag name are referred to as the tag "attributes". For example, see the <div> tag below, where the attribute is "align", or the image tag, where the attributes are "alt", "height", and "width". Attribute values modify the the way the tag works in some way. Here is a list of some HTML tags and some common attribute-value pairs for them. This is not an exhaustive list of attributes - there are many more, but this is enough to get you started using attributes. |
|||||||||||||||||
| How to use attributes and values in tags | |||||||||||||||||
|
Tag name
|
<Tag Attribute="Value">
|
||||||||||||||||
|
Div tag <div></div> |
<div align="center"> Centers whatever is contained in the <div></div> tags. |
||||||||||||||||
|
Image tag <img src="mypicture.jpg" / >
|
<img src="../images/yourpicture.jpg" alt="John Wilson with Elvis at Woodstock" height="105" width="156" / > alt height and width align="left"align="right" DEFAULT ALIGNMENT - If you do not specify an alignment inside
an image tag, all text will start at the bottom right corner of
the image and then wrap underneath the image, like this: LEFT ALIGNMENT - If you set the image to align="left" then
the image moves to the left, as you would expect, and the text
begins at the upper right hand corner of the image, like this:
MIDDLE By the way, align="right" and align="left" work the same way on whole tables, so you can actually wrap text around small tables, too. HINT: If you just want to put a picture (by itself) on the right or left or in the center, use a <div></div> tag set around the picture, like this: <div align="center"><img src=" " / ></div> In case you're wondering, no, you can't make the text wrap around a centered picture using simple HTML. You can also put an alignment in a table cell, which makes everything in that cell be right or center justified, like this: <td align="right"></td> The default is align="left" so you don't have to specify it. |
||||||||||||||||
|
Break tag <br / > |
<br clear="all" / > For example:
Here's
the same left-aligned image. This time I use <br clear="all" / >.Now I can start to the left again. |
||||||||||||||||
|
Link tag <a href=""></a> <a name=""></a> |
<a href="myfile.htm" target="_blank"> As previously explained, <a href="myfile.htm"> is the way you signify the web address of a link. Add target="_blank" to have the page open in a separate browser window. <a name="this"> The "name" attribute places a marker on the page so that you can jump right to it. In the link <a href="myfile.htm#this"> the browser will jump directly to the spot named "this" on the page "myfile.htm." Notice the # between the name of the file and the name of the marker. |
||||||||||||||||
|
Lists "Unordered" List:(bulleted)
|
Type="disc" is the default type for the first level of unordered list.
|
||||||||||||||||
|
"Ordered" List: |
Possible values of the "type" attribute are A, a, I, i and 1. They will display ABC, abc, I II III, i ii iii, or 1 2 3 etc. The default is 1 2 3 etc. Possible values of the "start" attribute are the numbers 1, 2, 3, 4, 5 etc. What you put in the "start" attribute is a number which shows which number or letter in the row to start on. For example, if you start at "5" with the type "A," the entries will be labeled E, F, G etc. The default is to start at the beginning. |
||||||||||||||||
|
<p> Tag <p>...</p> |
<P align="center"> Places the whole paragraph in
the center, with each line centered. |
||||||||||||||||
|
span tag <span>...</span> |
This tag is generally used with the "style" attribute, and is merely a container for the particular style. Styles The style attribute is an "in-line" version of a stylesheet, and you can override a style sheet by including a different style inside a tag (any tag). The <span> tag is just a convenient one to use if you don't have another tag close by to use. Styles use a slightly different syntax than HTML just to drive us crazy. Click here for a styles/HTML comparison chart. |
||||||||||||||||
|
Table tags |
|
||||||||||||||||
| <table>...</table> |
<table width="94%" border="1" cellspacing="5" cellpadding="4"> <table width="500" border="0" cellspacing=0 cellpadding="0" bgcolor="#FFEEEE"> The width can be either a percentage or an absolute number, measured in pixels. A border of "1" is actually two pixels. Cellspacing is the area between cells. Here is a small table with a cellspacing of 5. Cellpadding is the area between the edge of a cell and the text and images inside it. Here is a table with a cellpadding of 0.
Here is a table with a cellpadding of 5.
Here is a table with a cellspacing and cellpadding of 5.
Background Colors: If you would like to add a color to the background of your table, include the bgcolor attribute. The colors are represented by six numbers, two for red, two for green and two for blue: rrggbb. The colors are represented by "hex numbers," which use a base 16 numbering system (Hexadecimal, or "hex.") The numbers are: 0 1 2 3 4 5 6 7 8 9 A B C D E F. "0" is the lowest value, and the darkest, because the RGB system is light, not pigment. No light, no color, hence "#000000" is black. If all the numbers are as high as they can go, you have #FFFFFF, or white. Since the web uses light to paint with instead of pigment, mixing all the colors together makes the lightest color, white. #FF0000 is bright red, #00FF00 is bright green, and #0000FF is bright blue. Be a bit careful when using colors in your tables. If you use a dark color for your background, change the color of the text on it to make sure there is enough contrast. Black lettering on a dark blue background is a tad difficult to read. Likewise, never ever ever use red text on a blue background or vice versa.The eye makes subtle adjustments to see colors of different wavelengths, and since red has the longest wavelength of the visible spectrum, and blue the shortest, the eye tends to jump back and forth, creating an annoying vibration. It is customary to indicate the hex colors with a "#" in front of them. Some browsers won't recognize the colors unless you do. It looks like this: <table bgcolor="#FFEEEE"> |
||||||||||||||||
| <tr>...<tr> | <tr valign="top"> This aligns all of
the contents of the cells in this row at the top.
|
||||||||||||||||
| <caption>... </caption> |
<caption valign="bottom" align="right"> puts a table caption below the table, flush with the right edge of the table. <caption valign="top" align="center"> This is the default, with the caption is centered over the top of the table. |
||||||||||||||||
| <th>...</th> <td>...</td> |
<th align="center" width="60" bgcolor="#333366"> Alignment inside table cells, both <th> and <td>: <td align="left"> This is the default. Merged Cells:
Please note that mixing colspans and rowspans in the same column or row will probably give bad results. |
||||||||||||||||