HTML Attributes
Attributes provide additional information about HTML elements.
Attributes typically appear in the opening tag of an HTML element and define the element's behavior, style, content, or other characteristics.
Attributes are always written inside the tag in the form name="value",name is the name of the attribute,value is the value of the attribute.
HTML Attributes
- HTML elements can haveproperty
- Attributes can be added to elementsAdditional Information
- Attributes are generally described inThe opening tag
- Attributes always appear in name/value pairs,For example: name="value"。
Attribute examples
HTML links are defined by the tag. The link's address is specified in the href property:
Example
<
a
href
=
"
http://www.runoob.com
"
This is a link
a
Try it »
HTML attributes commonly use quoted attribute values
Attribute values should always be enclosed in quotes.
Double quotes are the most commonly used, but single quotes work just as well.
Using double quotes:
Link
Using single quotes:
Link
Attribute values containing quotes:
Link
Tip: In some rare cases, such as when the attribute value itself contains double quotes, you must use single quotes, for example:
name='John "ShotGun" Nelson'or:
HTML Tip: Use lowercase attributes
Attribute and attribute value names are case-insensitive.
However, the World Wide Web Consortium recommends lowercase attributes/attribute values in its HTML 4 recommendation.
Newer versions of (X)HTML require lowercase attributes.
HTML Attribute Reference Manual
View the complete list of HTML attributes: HTML Tag Reference Manual。
The following lists attributes applicable to most HTML elements:
Tip: In some rare cases, such as when the attribute value itself contains double quotes, you must use single quotes, for example: