June 16, 2000 - HTML Tag Types | WebReference

June 16, 2000 - HTML Tag Types

Yehuda Shiran June 16, 2000
HTML Tag Types
Tips: June 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

There are different ways to open and close HTML tags. The trivial one calls for just an opening delimiter. The List Item tag (<LI>) is a good example for a tag that does not need a closing delimiter. The more popular type is a pair of delimiters (one for opening and one for closing). The following examples demonstrate this type:

<A ......> ..... </A>
<TABLE .........> ...... </TABLE>
<CENTER ....> ...... </CENTER>
<BODY .....> ..... </BODY>

Notice the HTML code between the opening and closing tags (dots above). This is the body of the page for the <BODY> </BODY> pair, or the table body for the <TABLE> </TABLE> pair above. When you don't need to place any HTML code between the tags, you can omit the closing tag and place a forward slash at the end of the opening tag. For example,

<BODY .....> </BODY>

is equivalent to

<BODY ...../>

Take the following tag:

<BODY BGCOLOR="yellow"/>

and see that you get a yellow-background page. You cannot put anything on this page (empty tag), but you get the idea. In our columns, tips, and tutorials, we avoid using this short notation. We prefer the explicit one:

<BODY BGCOLOR="yellow"></BODY>