HTML Attributes

Attributes define additional properties of an element.

HTML Attributes

Certain parameters are frequently included within the opening tag to provide additional element properties (such as colorization, measurement, location, alignment, or other appearances) to the data between the markup tags. These parameters are called Attributes.

 

Note:Attributes are always specified in the start tag (or opening tag), and they can only contain the value of the attribute.


Attribute Values

Most attributes require a value. In HTML, the value can be left unquoted if it doesn't include spaces (name=value), or it can be quoted with single or double quotes (name='value' or name="value"). By the way, it is recommended to enclose Attribute values in quotes.

For example, the abbr element, which represents an abbreviation, expects a title attribute with its expansion. This would be written as:

<abbr title="Hyper Text Markup Language">HTML</abbr>
 

Tip:In some rare situations, when the attribute value itself contains quotes, it is necessary to wrap attribute value inside single quotes: name='John ''Williams'' Jr.'


Attribute Example

In the example below href is attribute and the link provided is its value.

HTML links are defined with the <a> tag. You will learn about links in upcoming tutorials.

  • <!-- link to tutorialrepublic.com -->
  • <a href="http://www.tutorialrepublic.com">Tutorial Republic</a>
  • <!-- link to google.com -->
  • <a href="http://www.google.com">Google</a>
 

Note:Attribute values are generally case-insensitive, except certain attribute values, like the id and class attributes. However, World Wide Web Consortium (W3C) recommends lowercase for attributes values in their specification.

A complete list of attributes for each HTML element is listed inside: HTML Tag Reference.

 
Close

Your Feedback:

 

We would love to hear from you! Please say something.