HTML attributes
HTML tags can have attributes. Attributes provide more information about HTML elements.
Attributes always appear in the form of name/value pairs, such as: name="value".
Attributes are always specified in the opening tag of an HTML element.
Example
HTML links are defined by the <a> tag. The link's address is specified in the href attribute:
<a href="http://www.php.cn">This is a link</a>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>php.cn</title> </head> <body> <a href="http://www.php.cn">This is a link</a> </body> </html>
Code running result:
Example explanation: By clicking "This is a link" above, you will jump to http:// www.w3school.com.cn This website
##Attribute example 1:
<h1> Defines the beginning of the title.<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>php.cn</title> </head> <body> <h1 align="center">标题</h1> </body> </html>Explanation: Center the <h1> title title
##Attribute example 2:< body> defines the body of the HTML document.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>php.cn</title> </head> <body bgcolor="yellow"> </body> </html>
Explanation: The above code means to set the background color of the web page to yellow
Tips
:Attributes and attribute values are not case sensitive sensitive. Newer versions of (X)HTML require lowercase attributes.
Always enclose attribute values in quotes Attribute values should always be enclosed in quotes. Double quotes are the most commonly used, but there is no problem using single quotes.
In some individual cases, such as the attribute value itself contains double quotes, you must use single quotes, for example:
name='Bill "HelloWorld " Gates'
HTML Properties Reference Manual
Our complete HTML Reference Manual A complete list of legal attributes available for each HTML element is provided:
Complete HTML Reference Manual
Attributes that apply to most HTML elements are listed below:
Attribute | Value | Description |
classname | Specifies the class name of the element | |
id | Specifies the unique id of the element | |
style_definition | Specifies the inline style of the element | |
text | Specifies additional information for the element (can be found in the tooltip Display) |