Home > Article > Web Front-end > HTML attribute_html/css_WEB-ITnose
HTML attributes provide additional information for HTML elements (providing more information about HTML elements).
Attributes always appear as name/value pairs, for example: name="value".
Theattribute is always specified in the opening tag of an HTML element.
<img src="1.jpg" alt="图片1" /><a href="www.aaa.html" title="aaa网址">aaa</a>
Explanation: The img element contains the src attribute and alt attribute; the a element contains the href and title attributes.
src attribute: Reference image, its value is the URL of the image file, which can be a relative path or an absolute path.
alt attribute: Specifies alternative text when the image cannot be displayed.
href attribute: used to specify the URL of the hyperlink target, which can be a relative path or an absolute path.
title attribute: Specifies additional information about the element. Try it: aaa Here we can move the mouse over the hyperlink text (aaa), and the title information (aaa URL) will appear.
Common Attributes
The following attributes are listed for most HTML elements:
class | classname | 规定元素的类名(classname) |
id | id | 规定元素的唯一 id |
style | style_definition | 规定元素的行内样式(inline style) |
title | text | 规定元素的额外信息(可在工具提示中显示) |