Now that you have been intrroduced to the basics of HTML in the previous sections, the intent of this section is to give you
an idea of what else is available in HTML so that even if you do not choose to cover all the detailed topics ahead, you will at
least have a working knowledge of HTML and its major functions. This section covers the basic ideas of the following topics.
The background attribute places an image at background. For this, you need to have a small image available in your folder.
Any small image will do since the browser automatically repeats it to fill the entire page. If you don't have an image for this
exercise, you can right-click on the image provided here on the right and save it to your folder as 'mybg1.gif'. Then use the
following code to see what it would look like when applied as a background.
Another use of the anchor tag is to direct your visitors to another part of the same web page. For this, you have to place a
position marker by using <a name="1"> at that position. Then, <a href="#1">anchor</a>
will take you to that
position. For example, we have placed several markers just above the headings of the different sections of this page, one of which
is just above "Text formatting"; clicking on the following link will take you there.
Do you want to review text formatting?. The 'Back' button of your browser will bring you back here. Note that
you can use any marker value instead of "1" such as "xxx", however, numbers make it more convenient for the page designer lest
loosing track of many markers on a page. Finaly this code is used to go to the top of the page:
To use an image as an anchor: We mentioned earlier that the anchor of a link can also be an image. To accomplish this,
all you have to do is place the image tag inside the anchor tag as demonstrated by the following example.
To use an image as a hyperlink
Code
<a href="http://www.yahoo.com" title="Go to Yahoo!"><img src="yahoo.jpg" border="0" /></a>
To design a table, you must know before-hand how many rows and how many cells in a row you need. The sizes of the cells, if not
specified by an attribute, are determined by the size of the largest content. Also, the content of the cell is vertically centered but
left aligned. The browser assumes the same number of cells in each row, if you have one cell in the first row and two in the
second, the output may look strange if you did not use the appropriate attributes.
In fact, just like all other tags, tables are not that appealing without using attibutes. The table tag has several attributes
some of which are align="left | right | center", bgcolor="", border="", width="", cellspacing="",
cellpadding="". No explanation is required for the first four, cellspacing="" specifies the space between
cells in pixels, cellpadding="" specifies the space between the edges of the content and the edges of the cell.
The cell tag <td> also has bgcolor="" and width="" attributes, but more importantly, its
colspan="" and valign="" are very useful. The colspan=""
tag takes a numerical value and is used to combine rows so as to form wider cells. The valign="top | middle | bottom | baseline"
tag is used to vertically align the content of the cell.
Many of the attributes of the row tag <tr> are similar to those of the cell tag.
Now let's see a modified version of the previous example, to which we have added one more row at the top to serve as a title.
Notes: The attributes of the <table> tag:- the border="2" attribute produces borders (of tickness 2px) around all cells and the entire table; width="100%"
makes the table fill its container left to right (in the previous example everything was to the left of the container); cellpadding="10" creates spaces of 10px
all around the content (especially on left, top, bottom).
The attributes of the newly added row cell:- align="center" centers the content of the cell, the other contents are not; bgcolor="silver"
specifies the cell's background color; colspan="2" combines two cells into one, this is important since the other two rows have two
cells while this one has only one.