Web Design - Introduction to HTML: Formatting Text

Sections:   Introduction  |  Section 1  |  Section 2  |  Section 3  |  Section 4  |  Section 5
Section Two:  Part A  |  Part B  |  Part C  |  Part D  |  Part E  |  Part F  |  Part G

Attributes

Attributes

As you have learned, HTML is a collection of tags you use to ‘markup’ plain text for viewing in a web browser. Most HTML tags can have attributes added to them. Attributes provide extra information about the tag as well as extend a tag's display and functionality.

Attributes:

  • Can be added to most (but not all) HTML tags.
  • Are always listed in the opening tag.
  • Are listed as name/value pairs – represented as: name=”value”.
  • Can be added with other attributes, to the same tag.

In previous text, it was mentioned that the <p></p> tags could be used to align the text listed between them. To do this you would use an attribute. The attribute that will allow us to align text listed between the <p></p> tags is: align="left/center/right/justify" where left, center, right, and justify are different values that can be set to the align attribute.

Notice the bullet above about attributes: "attributes are listed as name/value pairs – represented as: name=”value”. In the above bolded align example (align="left/center/right/justify"), align is the attribute "name" and "left, center, right, or justify" is the value associated with that attribute name. There are a couple of things to understand about attribute name/value pairs:

  1. The equal symbol assigns the value to the attribute name.
  2. The attribute value must always be place with quotation marks around it.

Extend Your Learning - Attributes

Imagine that the editor of the online newspaper you work for wants you to center align each paragraph in your article. You could achieve this by using the following<p></p> tags and their associated align attribute.

attribute example

Next Next

© 2008 KCDL. All rights reserved.