1. Home
  2. Computing & Technology
  3. Web Design / HTML

How to Add an Attribute to an HTML Tag

By , About.com Guide

Attributes modify HTML tags and provide additional information to the Web browser. They are easy to add to HTML tags.

A basic HTML tag starts with the < character, the tag name, and finishes with the > character. For example:

<p>

To add an attribute to your HTML tag, put a space after the tag name. Then add the attribute name, an equal sign, and the attribute value in quotation marks. For example:

<p style="color:red;">

Tags can have multiple attributes. Separate each attribute from the others with a space.

<p style="color:red;" title="first paragraph">

It's a good idea to surround all attribute values with double quote marks. You can also use single quotes. If you're writing HTML (as opposed to XHTML), you can leave off the quotation marks if there are no spaces in your attribute value. But I don't recommend getting into that habit. Quoting attributes is a good idea to keep your HTML from having problems.

Explore Web Design / HTML
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. HTML and XHTML
  5. Beginning HTML Tutorials
  6. How to Add an Attribute to an HTML Tag>

©2009 About.com, a part of The New York Times Company.

All rights reserved.