HTML attributes


Attributes are additional information provided by HTML elements.

  • HTML elements can set attributes

  • Attributes can add additional information# to the element

  • ##Attributes are generally described in the

    start tag

  • Attributes always appear in the form of name/value pairs,

    For example: name="value".


Property Example

HTML links are defined by the <a> tag. The address of the link is specified in the

href attribute :

Instance

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php中文网(php.cn)</title>
</head>
<body>

<a href="//m.sbmmt.com">这是一个链接使用了 href 属性</a>

</body>
</html>

Running instance» Click the "Run Example" button to view an online example



HTML attributes commonly quoted attribute values

Attribute values ​​should always be enclosed in quotation marks.

Double quotes are the most commonly used, but there is no problem using single quotes.

lamp.gifTips: In some individual cases, such as the attribute value itself contains double quotes, you must use single quotes, for example: name='John "ShotGun" Nelson'


HTML Tip: Use lowercase attributes

Attributes and attribute values ​​are not case-sensitive.

However, the World Wide Web Consortium recommends lowercase attribute/attribute values ​​in its HTML 4 recommendations.

The new version of (X)HTML requires the use of lowercase attributes.


HTML Attribute Reference Manual

View the complete list of HTML attributes:

HTML Tag Reference Manual.

The following attributes are listed for most HTML elements:

AttributesDescriptionclassDefine one or more class names (classname) for html elements (class names are introduced from style files)idDefine the unique id of the elementstyleSpecify the inline style of the elementtitleDescribes additional information about the element (used as a toolbar)More standard attribute descriptions: HTML Standard Attributes Reference Manual.