Copyright © 2001 Weblink I.T. Limited. All Rights reserved.
A typical page would almost certainly contain most of the following elements:
HTML has six levels of headings, numbered 1 through 6, with 1 being the largest. Headings are typically displayed in larger and/or bolder fonts than normal body text. The first heading in each document should be tagged <H1>.
The syntax of the heading element is:
<Hy>Text of
heading</Hy>
where y is a number between 1 and 6 specifying the level of the
heading.
Do not skip levels of headings in your document. For example, don't start with a level-one heading (<H1>) and then next use a level-three (<H3>) heading.
Unlike documents in most word processors, carriage returns in HTML files aren't significant. In fact, any amount of whitespace -- including spaces, linefeeds, and carriage returns -- are automatically compressed into a single space when your HTML document is displayed in a browser. So you don't have to worry about how long your lines of text are. Word wrapping can occur at any point in your source file without affecting how the page will be displayed.
In the minimal example shown below, the first paragraph is coded as
<P>Welcome to the web site design course.
This is a short paragraph.
While short it is
still a paragraph!</P>
In the source file there is a line break between the sentences. A Web browser ignores this line break and starts a new paragraph only when it encounters another <P> tag.
Important: You must indicate paragraphs with <P> elements. A browser ignores any indentations or blank lines in the source text. Without <P> elements, the document becomes one large paragraph. (One exception is text tagged as "preformatted," which is explained below.) For example, the following would produce identical output as the first bare-bones HTML example:
<H1>Level-one heading</H1>
<P>Welcome to the web site design course. This is the
first paragraph. While short it is still a
paragraph! </P> <P>And this is the second paragraph.</P>
To preserve readability in HTML files, put headings on separate lines, use a blank line or two where it helps identify the start of a new section, and separate paragraphs with blank lines (in addition to the <P> tags). These extra spaces will help you when you edit your files (but your browser will ignore the extra spaces because it has its own set of rules on spacing that do not depend on the spaces you put in your source file).
NOTE: The </P> closing tag may be omitted. This is because browsers understand that when they encounter a <P> tag, it means that the previous paragraph has ended. However, since HTML now allows certain attributes to be assigned to the <P> tag, it's generally a good idea to include it.
Using the <P> and </P> as a paragraph container means that you can center a paragraph by including the ALIGN=alignment attribute in your source file.
<TT><P ALIGN=CENTER></TT>
This is a centered paragraph.
[See the formatted version below.]
</P>
This is a centered paragraph.
It is also possible to align a paragraph to the right instead, by including the ALIGN=RIGHT attribute. ALIGN=LEFT is the default alignment; if no ALIGN attribute is included, the paragraph will be left-aligned.
Use the<PRE> tag (which stands for "preformatted") to generate text in a fixed-width font. This tag also makes spaces, new lines, and tabs significant -- multiple spaces are displayed as multiple spaces, and lines break in the same locations as in the source HTML file. This is useful for program listings, among other things. For example, the following lines:
<PRE>
c:
cd\
cd develop\hbi
xcopy *.* c:\inetpub\wwwroot\hbi /s/e/v
xcopy *.* c:\progra~1\apache~1\apache\htdocs\hbi /s/e/v
cd\
</PRE>
display as:
c:
cd\
cd develop\hbi
xcopy *.* c:\inetpub\wwwroot\hbi /s/e/v
xcopy *.* c:\progra~1\apache~1\apache\htdocs\hbi /s/e/v
cd\
The <PRE> tag can be used with an optional WIDTH attribute that specifies the maximum number of characters for a line. WIDTH also signals your browser to choose an appropriate font and indentation for the text.
Hyperlinks can be used within <PRE> sections. You should avoid using other HTML tags within <PRE> sections, however.
Note that because <, >, and & have special meanings in HTML, you must use their escape sequences (<, >, and &, respectively) to enter these characters. See the section Escape Sequences for more information.
Use the <BLOCKQUOTE> tag to include lengthy quotations in a separate block on the screen. Most browsers generally change the margins for the quotation to separate it from surrounding text.
In the example:
<P>Britain's favourite poem.</P>
<BLOCKQUOTE>
<P>
IF you can keep your head when all about you
Are losing theirs and blaming it on you;
IF you can trust yourself when all men doubt you
But make allowance for their doubting too;
IF you can wait and not be tired by waiting,
Or being lied about, don't deal in lies,
Or being hated don't give way to hating,
And yet don't look too good, nor talk too wise:
</P>
<P>--Rudyard Kipling </P>
</BLOCKQUOTE>
the result is:
Britain's favourite poem.
IF you can keep your head when all about you Are losing theirs and blaming it on you; IF you can trust yourself when all men doubt you But make allowance for their doubting too; IF you can wait and not be tired by waiting, Or being lied about, don't deal in lies, Or being hated don't give way to hating, And yet don't look too good, nor talk too wise:
--Rudyard Kipling
The <BR> tag forces a line break with no extra (white)
space between lines. Using <P> elements for short lines of
text such as addresses results in unwanted additional white space. For
example, with
:
Amey Vectra Training<BR>
Tel (01684) 896525<BR>
Fax (01684) 896266<BR>
The output is:
Amey Vectra Training
Tel (01684) 896525
Fax (01684) 896266
The <HR> tag produces a horizontal line the width of the browser window. A horizontal rule is useful to separate major sections of your document.
You can vary a rule's size (thickness) and width (the percentage of the window covered by the rule). Experiment with the settings until you are satisfied with the presentation. For example:
<HR SIZE=4 WIDTH="50%">displays as: