| Music | Writing | Travelogues | Shakespeare Resource Center | Contact | |
Introduction | Required Tags | Formatting, Part I | Formatting, Part II | Links | Lists | Tables | Images | Other Resources
First, a refresher. You remember that HTML is defined by markup tags, usually in pairs, that follow a format of <TAG>content</TAG>. In the previous lesson, you learned that an HTML document is defined by <HTML> tags, and requires a minimum of three other tags to be a valid document: <HEAD>, <TITLE>, and <BODY>. This gives us the following framework:
<HTML>
<HEAD>
<TITLE>Title of Document</TITLE>
</HEAD>
<BODY>
Contents of Page
</BODY>
</HTML>
We modified this document to present the Gettysburg Address:
<HTML>
<HEAD>
<TITLE>The Gettysburg Address</TITLE>
</HEAD>
<BODY>
Four score and seven years ago our fathers brought forth on
this continent a new nation, conceived in liberty and dedicated
to the proposition that all men are created equal.
Now we are engaged in a great civil war, testing whether that
nation or any nation so conceived and so dedicated can long
endure. We are met on a great battlefield of that war. We have
come to dedicate a portion of that field as a final resting place
for those who here gave their lives that that nation might live.
It is altogether fitting and proper that we should do this.
But, in a larger sense, we cannot dedicate--we cannot
consecrate--we cannot hallow--this ground. The brave men, living
and dead, who struggled here have consecrated it far above our poor
power to add or detract. The world will little note nor long remember
what we say here, but it can never forget what they did here. It
is for us, the living, rather, to be dedicated here to the
unfinished work which they who fought here have thus far so nobly
advanced.
It is rather for us to be here dedicated to the great task
remaining before us--that from these honored dead we take
increased devotion to that cause for which they gave the last
full measure of devotion; that we here highly resolve that these
dead shall not have died in vain; that this nation, under God,
shall have a new birth of freedom; and that government of the
people, by the people, for the people shall not perish from the
earth.
</BODY>
</HTML>
However, this led to some problems because we haven't applied any formatting to the text in between the <BODY> tags. What should have been a four-paragraph essay was rendered as one long, run-on paragraph. The first order of business is to break this up correctly. The easiest (and correct) way to do so is by applying paragraph tags, which are conveniently styled as:<P> and </P>. These tags mark the beginning and ending of a paragraph, for instance:
<P>Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty and dedicated to the proposition that all men are created equal.</P>
And thus, the entire code for our Gettysburg Page would appear like this:
<HTML>
<HEAD>
<TITLE>The Gettysburg Address</TITLE>
</HEAD>
<BODY>
<P>Four score and seven years ago our fathers brought forth on
this continent a new nation, conceived in liberty and dedicated
to the proposition that all men are created equal.</P>
<P>Now we are engaged in a great civil war, testing whether that
nation or any nation so conceived and so dedicated can long
endure. We are met on a great battlefield of that war. We have
come to dedicate a portion of that field as a final resting place
for those who here gave their lives that that nation might live.
It is altogether fitting and proper that we should do this.</P>
<P>But, in a larger sense, we cannot dedicate--we cannot
consecrate--we cannot hallow--this ground. The brave men, living
and dead, who struggled here have consecrated it far above our poor
power to add or detract. The world will little note nor long remember
what we say here, but it can never forget what they did here. It
is for us, the living, rather, to be dedicated here to the
unfinished work which they who fought here have thus far so nobly
advanced.</P>
<P>It is rather for us to be here dedicated to the great task
remaining before us--that from these honored dead we take
increased devotion to that cause for which they gave the last
full measure of devotion; that we here highly resolve that these
dead shall not have died in vain; that this nation, under God,
shall have a new birth of freedom; and that government of the
people, by the people, for the people shall not perish from the
earth.</P>
</BODY>
</HTML>
Which gives us this:
Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation or any nation so conceived and so dedicated can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we cannot dedicate--we cannot consecrate--we cannot hallow--this ground. The brave men, living and dead, who struggled here have consecrated it far above our poor power to add or detract. The world will little note nor long remember what we say here, but it can never forget what they did here. It is for us, the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us--that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion; that we here highly resolve that these dead shall not have died in vain; that this nation, under God, shall have a new birth of freedom; and that government of the people, by the people, for the people shall not perish from the earth. |
(For the actual example page, click here.)
Doesn't this look much more readable? Of course it does. All thanks to the simple addition of <P> tags.
We're going to take a moment to talk about tag attributes. An attribute is additional information within the tag that acts as a modifier. For instance, there may be a time that you want text to center on a page rather than align to the left. The way that this is specified in HTML is to add an attribute to the tag in the following manner:
<TAG attribute="value">Content</TAG>
Note: the quotation marks should always be included around the value for any attribute.
Paragraphs, for example, take the align attribute:
<P align="left">
Now we are engaged in a great civil war, testing whether that nation or any nation so conceived and so dedicated can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.
Note: the default alignment for paragraph tags is "left," so you will rarely need to use the above declaration.
<P align="center">
Now we are engaged in a great civil war, testing whether that nation or any nation so conceived and so dedicated can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.
<P align="right">
Now we are engaged in a great civil war, testing whether that nation or any nation so conceived and so dedicated can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.
There is one other basic way of forcing line breaks: the <BR> tag. This tag differs from the <P> tag in that it is a single tag, put exactly where you wish the line to break. For instance, if we wanted to break the following line into two lines:
When in Rome, do as the Romans.
We could do so easily by inserting a <BR> tag in the text like so:
When in Rome,<BR>do as the Romans.
Which would render the lines as follows:
When in Rome,
do as the Romans.
You now have the basics of formatting down pat. But what if you wanted to add a heading, or if you wanted to bold or italicize text? Don't worry, there are HTML tags that let you do all of those things and more. That's in our next lesson, Formatting, Part II.