The following tables will help you move around this page (which is quite long). Clicking on any cell in the first table will take you to that section of the page. Click on any cell in the second table will take you to an explanation of that tag.
There is a link <Return to top> which will return you to these tables.
What is HTML? | How HTML works | Unpaired tags | Paired tags | Examples | UNIX help |
unpaired tags | <doctype> | <br> | <hr> | <basefont*> | <meta> |
---|---|---|---|---|---|
paired tags | <html> | <head> | <title> | <body> | <p> |
<h#> | <address> | <nobr> | <center*> | <blockquote> | |
<pre> | <font*> | <b> | <i> | <big> | |
<small> | <strike*> | <sub> | <sup> | <tt> | |
<samp> | <u*> | <cite> | <code> | <em> | |
<lists> | <div> | <strong> |
Tags can be modified with attributes which have values. Before looking at some of these tags, a word or two about attributes; these are elements of HTML that allow you to have more control over the way your pages look. For example, instead of simply placing a horizontal rule <hr> on the page and letting it take the default value, you can specify its length and alignment using attributes with different values.
The generic form of an attribute is:
<html_tag attribute="value">
So, in the example mentioned above, to instruct the browser to display a horizontal line that will extend across three-quarters of the page from the left margin, you would use:
<hr width="75%" align="left">
As we go through some of the common forms of HTML markup, you will notice that many tags have sets of attributes that you can use.
As you get better at marking up documents, you'll begin to experiment with nesting tags. This means that you can instruct a browser to display an element of your page with multiple effects. For example, you can make a phrase
larger and bold
or
smaller and italicized.
What you must remember is that you should end your nested tags in the exact reverse order as you started them. The markup for the first example above would then look like this:
<font size="5"><b>larger and bold</b></font>
You can include comments within your html markup that will not be displayed by the browser. You can use this tag to place information about the document (or you) that only will be visible to people who view your source markup. It is also possible to include commands that instruct servers that access your page to perform different functions (which is beyond what we will do here).
The comment tag uses an opening markup of <!-- and a closing of -->. There must be one space after the second - of the opening markup and one space before the closing -. The comment is the text that appears in between the markup. Here's an example of a comment used in these demonstration pages:
<!-- These pages are intended to help you learn HTML markup -->
Return to top
Unpaired, which appear alone in your markup. These include:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
"http://www.w3.org/TR/html4/loose.dtd">!DOCTYPE identifies the document as having a specific type
HTML PUBLIC specifies the document type as an HTML file
"//W3C//DTD HTML 4.0 Transitional//EN" further specifies that the file uses elements defined in the World Wide Web Consortium's document type definition (DTD) for HTML 4.0. The term Transitional means that the document still used some deprecated elements
"http://www.w3.org/TR/html4/loose.dtd" is the locatioon of the DTD that describes this bersion of the markup language
You can cut and paste this declaration and those tht follow directly into your HTML and XHTML documents.
There is a version of this tag that we must use when we work with strict HTML 4.01. This means that we are following the rules of this version and are not using any deprecated tags. When you have clean CSS markup, this would be the DOCTYPE declaration that you would use:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
There is also a version to use when following the rules of HTML 4.01 and using frames:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
There is another set of DOCTYPE declarations for use with XHTML. There is one for transitional XHTNML, where you are following the rules of this version but using some deprecated tags:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
There is a version to use when closely following the rules of this version of the markup language:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
Finally, there is a version to use with frames:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" />
Return to top
Use line breaks to control the way in which you want the text to appear on the screen. The <br> tag is used in this sentence to break the line here
exactly where you want it to break - in this case, after the word "here".
The amount of space that is inserted by the browser after a line break
is much less than the amount of space that is inserted
after a paragraph break.
The <br> tag takes one attribute called <clear>, which is often used in conjunction with images (which we'll get to on another page). This attribute will cause the text to break around an image and continue below it, relative to the appropriate page margin. It takes three values:
Return to top
Horizontal rule, to which attributes can be added, such as:
There are different types of horizontal rules on the example page.
Return to top
You can use a relative value for the basefont by using a size="+ or -n". This will be displayed by the browser relative to the default font size, which is 3. basefont size="+2" would produce a font size of 5.
You should only have one basefont tag on the page, and it should be placed after the opening body tag. The markup might look like this:
<body>
<basefont size="4">
The basefont tag only affects text. It will not affect the text that is enclosed in certain other tags, for example, text in a paired H# tag or in a table.
Return to top
The meta tag must be included within the document's header and is used to supply additional information about your document which is sent out to the remote server by your server, just before it sends out the document. This information is supplied by including one or more of the following attributes.
A required http-equiv declaration that should be in every HTML or CXHTML page that you write specifies the character encoding that you are using. This information allows a browser to correctoyl render your page. Use this one:
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
You can copy and paste this declaration directly into the <head> container in your pages.
You could also use this tag to indicate that such information as keywords, or author's name is available.
Note that you must use either the <http-equiv> tag or the <name> tag, but not both. In addition, many servers cannot process this information and will ignore it.
For example, to include several keywords for this document, the author's name, and the date it expires, the following markup would be used:
<meta http-equiv="keywords" content="html, paired, unpaired tags">
<meta name="author" content="Rosenbaum">
<meta name="expires" content="1 Jan 2006">
If using XHTML, the markup would look like this:
<meta http-equiv="keywords" content="html, paired, unpaired tags" />
<meta name="author" content="Rosenbaum" />
<meta name="expires" content="1 Jan 2006" />
The information sent to server through which the browser is requesting your page would be:
content-type: text/html
keywords: html, paired, unpaired, tags
author: Rosenbaum expires: 1 Jan 2006
For another interesting use of the meta http-equiv tag, let's quickly go to another page. Don't worry, we'll be right back.
Return to top
Paired, which always must be opened and closed:There are four paired tags which should always appear in your web documents.
Return to top
Return to top
Do not use any special formatting or markup tags in the title of your document.
Return to top
You would use these standard tags in the following way:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Demo Page: Tags</title>
</head>
<body>
This is where the text would go
</body>
</html>
Return to top
Here are some other paired tags that you can use:
The closing </p> is typically omitted, and this does not violate the standard. However, when using cascading style sheets, the closing </p> tag is needed to mark the end of the application of a style.
All text between two <p> tags are considered to be in the same paragraph. The block of text is called an element.
A paragraph break <p> has one attribute which can take three values:
Note that you can't stack paragraph breaks to add extra lines between paragraphs. The second <p> is considered a redundant tag by the browser and is ignored. There are other ways to control white space, such as the use of cascading style sheets. By the way, this paragraph and the one that follows are preceded by the following markup:
<p align="right">
That's why these words are right justified and there is a ragged edge along the left side of these words.
Return to top
This tag is most useful when working with HTML 4.01, cascading style sheets and XHTML.
There's an example of the use of the div tag on the example page.
Return to top
Here are two examples:
This is the largest header (h1)
This is the smallest header (h6)
Headers can be positioned using the align attribute, which takes three values:
For example:
You can nest other html tags inside of h# markup; remember to close them in reverse order! Also, don't use h# markup to change the font characteristics of the page - there are better ways to this.
Return to top
<address>This page prepared by Howard Rosenbaum<br> Last update:12.31.99
</address>
It is displayed like this:
This page prepared by Howard Rosenbaum
Last update:12.31.99
Return to top
Return to top
The center tag also will center whatever else you include on your pages,including images, tables, and forms. You use one set of center tags to enclose all of the consecutive elements on the page that you want to appear in the center of the page. This term has been deprecated in HTML 4.01
Return to top
There's another example of a blockquote on the example page.To use it properly, you should use another tag, such as the <p> after the opening <blockquote> tag. As you can see, this paragraph has been enclosed in a pair of <blockquote> tags.
Return to top
You can use some HTML tags inside the paired pre tags. Those that force line and paragraph breaks cannot be used, but physical and logical tags can be used, although browsers will always use the monospaced font.
An interesting use of the pre tag is to insert a block of blank lines into a document. For example, here will be six blank lines after this sentence because of the use of the <pre>tag.
There's another example of the pre tag on the example page that shows how it preserves original spacing in an ASCII document.
Return to top
There are three main attributes that will work with this tag, size, face, and color. The first two will be discussed here, the third will be discussed on the Image and Color page.
You can use the font size tag to change a single character, a word, a sentence, or a paragraph.
The order of fonts should be from a specific font face (Times-Roman) to a general font family (Serif). The browser will go through the suggested fonts in order. The markup looks like this:
<font face="Times-Roman, Palatino, New York">text</font>
You can use this tag and its attributes as many times as you want in a document. You can also combine these attributes, for example:
<font face="Times-Roman, Palatino, New York" size="5">text </font>
Remember that it must always have the closing </font> tag
There are some examples of the font tag with the size and face attributes on the example page.
Return to top
Return to top
Rosenbaum. (1996). html Demonstration Pages.
fixed width font to display text
, but has the advantage of allowing the coded text (typically actual lines of code) to be extracted from the page by a search tool. This text is smaller than the default text displayed by the browser. If you are not displaying computer code, you should use the <tt> tag.
Return to top
Return to top
Want to know more? Here are links to other pages about HTML.Use the Back button to return to this page when you are ready to continue.
Demo Page Navigation: |
DemoPage contents | About html | UNIX help | HTML tags | Lists | Links | Images |
---|---|---|---|---|---|---|---|
Imagemapping | Tables | Forms | Frames | Javascript | CSS (style sheets) | XML |
Page by Howard Rosenbaum | |
Find me at [email protected] | http://www.slis.indiana.edu/hrosenba/www/Demo/Demo.html |