If you already know all about "attributes" in HTML tags, and if you already know how to use the 'ALIGN' attribute with the <P> tag, you can skip this lesson.
Normally, text passages are aligned "left" on the browser screen, that is, the beginning of each line is on the left margin, and the line is "ragged" on the right margin. Sometimes, we would like it to be the other way around. We can do this by including a special notation inside the paragraph tag.
<P ALIGN="RIGHT" >
This is the first tag we've encountered, in which we've made use of attributes. The attribute is a symbol (representing a static variable, for you programming types) that is embedded in the opening tag, and generally has an attribute name, an '=' sign, and an assigned value . The tag attributes already exist as document attributes in the browser, even though you haven't seen them yet, in the form of a hidden table somewhere in the browser's memory. Upon starting the browser, each document attribute is assigned a default value. "Default" just means that the browser decides ahead of time what attributes it is going to store, and what values they should have to begin with. Advanced browsers, like Netscape and Internet Explorer (among others), allow certain HTML tags to temporarily modify the working value of these attributes, and thus modify the screen behavior.
We are already quite familiar with the <P> tag: it causes a double end-of-line action that begins a paragraph. What we did not mention before, is that the browser has a hidden attribute associated with the 'paragraph' function, which for discussion purposes we'll call "Paragraph Alignment". Normally, paragraph alignment is set to its default value, which is (in pneumonic terms) "align left", or (in symbolic terms) ' ALIGN="LEFT"'. If we have an advanced browser, we can modify the value of that particular attribute, by including the attribute name and value (in quotation marks) inside the opening tag, separated from any other stuff (inside the tag) by at least one "space". Let's examine how we might use the "paragraph attribute" in a tag.
As with other tags we've seen with "stuff" embedded inside them, a "space" is required between the '<P' and the ' ALIGN='. Also, notice that the value for ' ALIGN=' is placed inside quotation marks. Additionally, it's good practice to eliminate any space on either side of the '=' sign. Be aware that the <P> tag is still a standalone tag, that is, it has no closing tag. The right alignment will endure until an empty <P> tag occurs (which makes it revert to the default left-alignment), or until a tag occurs which invokes an automatic paragraph. It's also good practice, if you explicitly made use of the ' ALIGN=', to explicitly change the alignment to "left" at the next paragraph. Normally, the browser will do this automatically, but there's no law that says it has to. Thereafter, you could continue with the empty tag. To explicitly align left, use this tag:
<P ALIGN="LEFT" >
You can also align a paragraph in the center (instead of using the <CENTER></CENTER> tag pair), by using the following alignment value:
<P ALIGN="CENTER" >
Let's look at some source code:
Here's a short passage from Shakespeare's <CITE>Romeo and Juliet</CITE> (aligned to the right): <P ALIGN="RIGHT"> When he shall die, <BR> take him and cut him out in little stars, <BR> and he will make the face of heaven so fine <BR> that all the world will be in love with night, <BR> and pay no worship to the garish sun. <BR> <P> and yet another from the same play (default alignment): <P > They may seize <BR> On the white wonder of dear Juliet's hand <BR> And steal immortal blessing from her lips, <BR> Who, even in pure and vestal modesty, <BR> Still blush, as thinking their own kisses sin.<BR> <P> and from his <CITE>Love's Labour's Lost </CITE> (center aligned): <P ALIGN="CENTER"> From women's eyes this doctrine I derive: <BR> They sparkle still the right Promethean fire; <BR> They are the books, the arts, the academes, <BR> That show, contain, and nourish all the world. <BR> <P ALIGN="LEFT">
Here's a short passage from Shakespeare's Romeo and Juliet (aligned to the right):
When he shall die,
take him and cut him out in little stars,
and he will make the face of heaven so fine
that all the world will be in love with night,
and pay no worship to the garish sun.
and yet another from the same play (default alignment):
They may seize
On the white wonder of dear Juliet's hand
And steal immortal blessing from her lips,
Who, even in pure and vestal modesty,
Still blush, as thinking their own kisses sin.
and from his Love's Labour's Lost (center aligned):
From women's eyes this doctrine I derive:
They sparkle still the right Promethean fire;
They are the books, the arts, the academes,
That show, contain, and nourish all the world.
This is a departure from the usual HTML functionality, in that the ALIGN= feature had limited duration, yet required no closing tag. (Don't ask me why they did that!) By the way, you'll notice that after the first passage (which was aligned right), I used an empty '<P>' tag. Did your browser switch back to left alignment automatically? Keep in mind that some early browsers may not support the embedded 'ALIGN=' feature, in which case they'll simply continue aligning left.