Attributes define additional properties of an element.
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.
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"). 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:
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.'
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.
ExampleTry this code »
<!-- link to tutorialrepublic.com -->
<a href="https://www.tutorialrepublic.com">Tutorial Republic</a>
<!-- link to google.com -->
Note: Attribute values are generally case-insensitive, except certain attribute values, like the
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.