A Complete Guide to Web Design

(やまだぃちぅ) #1
Layout Techniques with HTML 127

Formatting
Text

Layout Techniques with HTML

Web Design in a Nutshell, eMatter Edition

it is not a universal solution. The following code creates the same effect shown in
Figure 7-17:


<DIV ALIGN="center">
<H2>Choosing the Best Foods</H2>
<P>Good food gives more than immediate pleasure. It's a key to
your family's health and vitality, affecting the way young
people grow, the way you feel right now, and good health in
later years.</P>
<P>There are simple guides to help you plan meals that are
interesting and varied.</P>
</DIV>

The

tag


An extension to HTML, the

tag is extremely straightforward to use (and
for that reason, it is used commonly)—just place the
and

tags around sections of the page you would like to be centered, as shown in the
following code. You could place your whole page within
tags, if you’d
like, or just apply it to certain paragraphs. The
tag can only be applied
to block-level elements since it is illogical to center text within the flow of left-
aligned text.


<CENTER>
<H2>Choosing the Best Foods</H2>
<P>Good food gives more than immediate pleasure. It's a key to
your family's health and vitality, affecting the way young
people grow, the way you feel right now, and good health in
later years.</P>
<P>There are simple guides to help you plan meals that are
interesting and varied.</P>
</CENTER>

The<center>tag has been deprecated by the HTML 4.0 Specifica-
tion in favor of<DIV align=center>.

Right and Left Alignment


Thealignattribute is also used for specifying left alignment and right alignment
by setting its value toleftorright, respectively. The alignment will remain in
effect until the browser encounters another alignment instruction in the source.
Figure 7-18 shows the effects of setting the attribute to left or right.


Text aligned with thealignattribute will override any centering set
with the<center> tag.
Free download pdf