from John Gleason's HTML tutorials, with grateful acknowlegement
The center command is: ALIGN="CENTER" (no spaces around the equal
sign) and must be used in conjunction with a HEADER tag or the PARAGRAPH tag
as in:
<H2 ALIGN="CENTER">a heading goes here</H2>
or
<P ALIGN="CENTER">a paragraph or block of text goes here</P>
Here are some points to remember concerning these two centering commands.
In the first example, a "heading" is centered (as indicated by the H2), and remember that because we are using a Header tag, a blank line will automatically be inserted before and after the heading. For this section, my heading "CENTERING TEXT" was centered using the H3 Header tag.
The second example is used to center whole portions of text - which could be
several lines of text.
In other words, we are centering a "paragraph"
or "block of text" with each line centered on the screen
just as these lines are centered (hopefully).
To end centering a block of text,
we use the </P> tag which is the closing paragraph tag.
This </P> tag is a new tag for us
and one that you may not end up using all that often.
But it does have its uses and this is one of them.
Choose DOCUMENT SOURCE from the VIEW menu
if you want to see how I centered these lines.
In ALIGN="CENTER", the ALIGN part is called an attribute. In the first
example, ALIGN is the attribute for the Header tag. In the second example, ALIGN
is the attribute for the Paragraph tag. An attribute provides extra information
about the tag and the text it encloses. An attribute can have a value. In our
two examples, the ALIGN attribute has the value "CENTER". In the first
example, the browser is told to place (align) the heading in the "center"
of the line. If a viewer should make the browser screen smaller, the heading
will still remain centered in whatever the new screen size is. In the next example,
a heading will be centered. When you do the example, be sure to try also ALIGN="RIGHT"
and ALIGN="LEFT" (which is the default value if the ALIGN attribute
is not used).
The value must be enclosed in quotation marks if it contains anything more than letters, numbers, hyphens and/or periods. Otherwise placing the quotes around the value is optional. Since our two examples have only letters in the value ("CENTER"), the quotes may be omitted. If you are ever in doubt about the quotes, then just put them in. Of course the attribute and value do not have to be written in upper case (capital) letters either. They may be written in lower case. The maximum length of an attribute and its value is 1024 characters including the quotation marks if used.
ALIGN="CENTER" is also called a "command within a command". The first command (ALIGN), tells the browser to align something and the second command (CENTER) tells the browser to align it in the center.
Sometimes you will see documents use only the CENTER command (no ALIGN="CENTER")
to center text as in:
<CENTER>
.
.
all lines or blocks of text will be centered between these two tags
.
.
</CENTER>
<CENTER> is one of the first Netscape extension tags and, as is the case with many Netscape extension tags, not supported by a number of browsers. ALIGN="CENTER" is part of HTML 3.2 and already accepted by most browsers. You are therefore strongly encouraged to use ALIGN="CENTER" for centering headings and paragraphs of text. If a browser does not support the CENTER tag, the headings and text will simply be left justified. We will be using the ALIGN="CENTER" command in the next example.