Basic HTML Tutorial

BHP HTML Basics - Using Attributes


Giving a Tag More Character
The control that you have using a simple tag like <P> is somewhat limited. Yes, it can start a new paragraph and move the text down on the page but that's not a really big thrill after you have done it a time or two. There is an easy way to expand the characteristics that a tag has by using something called an attribute.
An attribute is a named characteristic of a tag. It is placed inside the "<" and ">" brackets of the tag. The attribute has a name and may have an associated value. For example, to increase the capability of the <P> tag we can use an attribute named ALIGN. This will control the alignment of the text on the web page. The attribute ALIGN is used something like:

<P ALIGN="center">

or

<P ALIGN="left">

or

<P ALIGN="right">

In this example, the attribute's name is ALIGN and its associated values are center, left, or right.
The effect of using the attribute can be seen in these examples:
If we use something like:

<P ALIGN="center">
Put me in the center.

Then the resulting text will look like:

Put me in the center.
If we use something like:

<P ALIGN="right">
Put me on the right.

Then the resulting text will look like:

Put me on the right.
If we use something like:

<P ALIGN="left">
Leave me on the left.

Then the resulting text will look like:

Leave me on the left.
You may have noticed that the results of using the tag <P ALIGN="left"> looked exactly like using a plain <P> tag. That is because the ALIGN="left" attribute of the <P> tag is the default value, or the value that will be used if no ALIGN attribute is specified.
Grab the Code
Review
We have examined the use of attributes to expand the capabilities of our tags. Using the ALIGN attribute of the <P> tag, we can now place text on the left, right or in the center of the page.
In the next section, we will look at using some attributes in the <BODY> tag to control the color of our page and the text.
Back Next
[Back] [Table of Contents] [Next]
Copyright 2000 John H. Bolgiano, Jr. - All rights reserved
Modified with permission for educational use by Roberta Bush