HTML Attributes

Definition

  • HTML tags contain have one or more attributes are support.

  • HTML Attributes are added in tag to provide the more additional information about how the tag should be appear or behavior.

  • HTML Attributes are always specified in the start tag.

  • HTML Attributes consist on name/value pairs like: i.e. name="value" and separated by an equals (=) sign.

  • Attribute values always be enclosed in double/single quotes.

  • Double quotes are the most common use, but single quotes are also allowed.


HTML Attributes (Global Attributes)

Many attributes are in HTML elements, some are common attributes and others can only be used on certain tags.

Some of the more common attributes are:

Tag Value Description
id ID Name Declared unique id for the element.
class Class Name Used in Cascading Style Sheet (CSS).
style CSS properties CSS code specifies inline the HTML element is presented.
title Title Description Display on the "tooltip" for your elements.

Attributes is most cases they are optional. Many HTML elements assign a default value to it's attributes. Means if you don't include that attribute, a value will be assigned default attributes.

Example

<html>
<head>
  <title>HTML Attributes Example</title>
  <style type="text/css">
    #second {
      color:#FF9966;
    }
  </style> 
</head>
<body>
  <p style="background-color:red;">First Attributes</p>
  <p id="second">Second Attributes</p>
  <p>Third Attributes</p>
  <p>
    <abbr title="Cascading Style Sheet">CSS</abbr>
  </p>
</body>
</html>

Run it...   »