1, the introduction of

Attributes are used to customize the behavior of elements. They are written as key-value pairs inside tags, such as < HTML lang=”en”>.

2. Global properties

A global attribute is an attribute that all elements can use.

2.1, id

The unique identifier of an element within a web page, globally unique, cannot have two identical ID attributes. Prefix the value of the ID attribute with (#) and place it in the URL as an anchor point to locate the element within the page.

2.2、 class

Used to classify web page elements.

2.3, the title

Add a caption to the element and hover over the title value

2.4 tabindex,

Property value is an integer that represents the order in which the focus of the page shifts after the user presses TAB.

  • Negative integer: usually -1
  • 0
  • Positive integer

In general, it is best to set the tabIndex property to 0 and traverse in natural order, unless there is a special layout.

2.5, the accesskey

Specifies a shortcut key for a web element to get focus, as long as the shortcut key is pressed, the element will get focus, requires a function key to work: Alt+ character key.

2.6、 style

Specifies the CSS style of the current element

2.7、 hidden

Boolean property that indicates that the current page element is no longer relevant to the page. But if the CSS makes the element visible, the hidden property is invalid.

2.8, lang, dir

The lang attribute specifies the language used by the web page element. Common values are zh, zh-Hans, zh-hant, en, es, fr Dir indicates how the text is read. There are three possible values: LTR, RTL, and auto.

2.9、 contenteditable

This property allows the user to modify the content and has two possible values: true and false. This property is an enumerated property, not a Boolean property, and is written with an attribute value. The user changes the sentence content, which is the same as before unless it is submitted to the server

2.10、 spellcheck

This property indicates whether to turn on the browser’s native spelling checker and has two possible values: true and false. Use with Contenteditable. This property is an enumerated property, not a Boolean property, and is written with an attribute value.

2.11, the data

This property is used to place custom data.

2.12. Event handling properties

Event Handler The event handler property is used in response to the user’s actions, and the value of the property is JavaScript code. Onblur lose focus onchange state change onclick Click onClose ondbclick double-click onfocus get focus onKeyUp mouse lift onScroll scroll onabort, onAutoComplete, onautocompleteerror, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, onclose, oncontextmenu, oncuechange, ondblclick, ondrag, ondragend, ondragenter, ondragexit, ondragleave, ondragover, ondragstart, ondrop, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onsort, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting