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 ExampleHTML links are defined by the <a> tag. The address of the link is specified in the
href attribute :
Instance
Running instance» Click the "Run Example" button to view an online example
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <a href="http://www.php.cn">这是一个链接使用了 href 属性</a> </body> </html>
Running instance» Click the "Run Example" button to view an online example
HTML attributes commonly quoted attribute valuesAttribute values should always be enclosed in quotation marks. Double quotes are the most commonly used, but there is no problem using single quotes.
Tips: 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 attributesAttributes 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 ManualView the complete list of HTML attributes:
HTML Tag Reference Manual.
The following attributes are listed for most HTML elements:Description | |
---|---|
Define one or more class names (classname) for html elements (class names are introduced from style files) | |
Define the unique id of the element | |
Specify the inline style of the element | |
Describes additional information about the element (used as a toolbar) |