html element attributes include: accesskey, class, contenteditable, contextmenu, "data-*", dir, draggable, dropzone, hidden, id, lang, spellcheck, style, etc.
The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.
What are attributes
Attributes can provide some additional information for HTML tags, or modify HTML tags. Attributes need to be added in the start tag, and the syntax format is:
attr="value"
attr represents the attribute name, and value represents the attribute value. Attribute values must be surrounded by double quotes " " or single quotes ' '.
Note that although both double quotes and single quotes can surround attribute values, for the sake of standardization and professionalism, please use double quotes as much as possible.
A tag can have no attributes, or it can have one or more attributes.
There are many HTML attributes, which can be roughly divided into two categories:
Some attributes are applicable to most or all HTML tags. We call these attributes universal attributes;
Some attributes are only applicable to one or a few specific HTML tags. We call these attributes special attributes.
Common properties (global properties)
Properties | Description |
---|---|
accesskey | Sets the keyboard shortcut for accessing an element. |
class | Specifies the class name of the element |
contenteditable | Specifies whether it can be edited The content of the element. |
contextmenu | Specifies the context menu of an element. When the user right-clicks the element, a context menu appears |
data-* | Used to store custom data for the page |
dir | Set the text direction of the content in the element. |
draggable | Specify whether an element can be dragged |
dropzone | Specify whether to drag data Copy, move, or link, or delete |
hidden | The hidden attribute specifies that the element is hidden. |
id | Specifies the unique id of the element |
lang | Set the language code of the content in the element . |
spellcheck | Detect whether the element is spelled incorrectly |
style | Specify the inline style of the element (inline style) |
tabindex | Set the tab key control order of elements. |
title | Specifies additional information for the element (can be displayed in a tooltip) |
translate | Specify whether the value of an element needs to be translated when the page is loaded |
Special properties
The following will introduce to you the properties of several commonly used tags
Attributes | Value | Description |
---|---|---|
charset | char_encoding | HTML5 Not supported. Specifies the character encoding of the target URL. |
coords | coordinates | HTML5 Not supported. Specifies the coordinates of the link. |
download | filename | Specify download link |
href | URL | Specifies the target URL of the link. |
hreflang | language_code | Specifies the base language of the target URL. Only used if the href attribute is present. |
media | media_query | Specifies the media type of the target URL. Default value: all. Only used if the href attribute is present. |
name | section_name | HTML5 Not supported. Specifies the name of the anchor. |
rel | alternate author bookmark help license next nofollow noreferrer prefetch prev search tag |
Specifies the relationship between the current document and the target URL. Only used if the href attribute is present. |
rev | text | HTML5 Not supported. Specifies the relationship between the target URL and the current document. |
shape | default rect circle poly |
HTML5 is not supported. Specifies the shape of the link. |
target | _blank _parent _self _top framename |
specifies where to open the target URL. Only used if the href attribute is present.
|
type | MIME_type | Specifies the MIME type of the target URL. Only used if the href attribute is present. Note: MIME = Multipurpose Internet Mail Extensions. |
Attributes | Value | Description |
---|---|---|
accept | MIME_type | HTML5 Not supported. Specifies the type of file received by the server. (Files are submitted via file upload) |
accept-charset | character_set | Specifies the form data that the server can process character set. |
action | URL | Specifies where to send form data when the form is submitted. |
autocomplete | on off |
Specifies whether to enable the autocomplete function of the form. |
enctype | application/x-www-form-urlencoded multipart/form-data text/plain |
Specifies how to encode form data before sending it to the server. (Applicable to method="post") |
method | get post |
Specifies the HTTP method used to send form data . |
name | text | Specifies the name of the form. |
novalidate | novalidate | If this attribute is used, no validation will be performed when submitting the form. |
target | _blank _self _parent _top |
Specifies where to open the action URL. |
Tag attributes
Attributes | Value | Description |
---|---|---|
manifest | URL | Define a URL on which the description Document cache information. |
xmlns | http://www.w3.org/1999/xhtml | HTML is not supported. Only XHTML supported. Specify the XML namespace attribute (use this attribute if you need your content to conform to XHTML.). |
Attribute | Value | Description |
---|---|---|
disabled | disabled | Specifies that this option should be disabled on first load. |
label | text | Defines the label used when |
selected | selected | Specifies that the option appears selected (when first displayed in the list). |
value | text | Defines the option value sent to the server. |
. . . .
Related recommendations: "html video tutorial"
The above is the detailed content of What are the attributes of html elements?. For more information, please follow other related articles on the PHP Chinese website!