HTML attributes can add additional information to an element and are set in pairs (attribute name =” attribute value “).

Attribute values should always be enclosed in quotes (single or double). HTML is case insensitive, so attributes and attribute values are case insensitive, and lower case is recommended in HTML 4.

Example:

HTML links are defined by the A tag.

The address of the link is specified in the href attribute:

<a href=" https:// :baidu.com" >Copy the code
Attributes and meanings of most HTML elements

1. Class: Define one or more class names for HTML elements. Class names are not unique and can be used repeatedly.

Eg: Class attribute values are custom, can not use Chinese, use alphanumeric name whatever you want, do not recommend using numbers. <div class="box"></div>Copy the code

2. Id: Defines the unique ID of the element. The id value must be unique within a page and cannot be used repeatedly.

Eg: The ID name is defined by letters. Chinese characters and numbers cannot be used. <div id="box"></div>Copy the code

3. Style: Specifies the inline style of the element.

<div style="background:red; color: RGB (51, 51, 51); color:#fff"></div>Copy the code

4. Title: Describes additional information about the element. When the mouse pointer is over the element, the attribute value is displayed. Mainly used in website optimization.

Eg: <div title=" display text when hover over element "> element with title attribute </div>Copy the code