HTML attributes. How to use HTML5 data attributes Global html attributes
Along with attributes specific to specific tags, HTML5 also has a number of attributes that can be added to any tag, so the attributes included in this group are called global or universal attributes. They are listed below with brief description. Available via link detailed description attribute.
The accesskey attribute allows you to activate the link using some key combination with a letter or number specified in the link code. Browsers use different key combinations. For example, for accesskey="s" the following combinations work.
Specifies a style class that allows you to associate a specific tag with styling. It is allowed to specify several classes at once in the value, separating them with a space.
Informs that the element is editable by the user - it is allowed to delete the text and enter a new one. Standard commands like undo, paste text from clipboard, etc. also work.
Sets the context menu for an element. The value is the ID of the menu created using the tag
<
form
action
=
"process.php"
>
<
label
for
=
"email"
>Email :<
/
label
>
<
input
type
=
"text"
name
=
"email"
value
=
"gordo@example.com"
>
<
input
type
=
"submit"
formnovalidate
value
=
"Submit"
>
<
/
form
>
And this example shows the use of novalidate:
<
form
action
=
"process.php"
novalidate
>
To see a description and an example of how to use the global attribute you are interested in, click on it or scroll down the page to its description.
access key
The accesskey attribute is used by browsers as a guide to creating a keyboard shortcut that activates or brings focus to an element.
Note: Prior to HTML5, the accesskey attribute could only be used with the following tags: . ,
The value of the accesskey attribute must be a character that can be entered by pressing a single key. Whitespace characters are not allowed as an attribute value.
The keyboard shortcuts for the accesskey attribute depend on the browser you are using:
Using the accesskey attribute on different elements with the same value causes the attribute to be ignored.
class
The class attribute is used to later access elements (via the class name) in CSS and JavaScript.
In the class attribute, you can specify not one, but several classes as a value, in which case the class names must be separated by spaces, the order of the class names does not matter:
If ad blocks of different classes use the same CSS properties with different values, then the value that is defined below the rest in the CSS code will be applied to the property. Therefore, the order of the class names in the attribute value does not matter, since in this case the cascading mechanism is triggered.
contenteditable
The contenteditable attribute specifies whether the user can edit the content of this element. The attribute can take one of the following values:
true or an empty string ("") - the content of the element can be edited
false - content editing is prohibited
Just some text
draggable
The draggable attribute determines whether the user can drag the element using the drag-and-drop API. The attribute can take one of three values:
true - indicates that the element is draggable
false - indicates that the element is not draggable
auto - specifies that the dragging of the element will depend on the value set in the default browser.
Using the id attribute, you can create links to specific element, not just the page as a whole. Such links can lead either to a section of this page or to a section of another page. To link to an element, add an id attribute to the sky. The link itself, in this case, will have to contain the name of the identifier of the element to which it refers, which must be preceded by the # symbol. If the link leads to a section of the current page, then only the name of the identifier can be specified as the address, if the link leads to a section of another page, then the name of the identifier is indicated at the very end of the address:
language
The lang attribute allows you to specify which language is used for text within an element. Language codes are used as the attribute value:
English text: "Hello world!".
Using this attribute helps browsers to correctly display certain national characters, speech programs to determine the language of the text, and checks the text for spelling and grammar checkers.
The lang attribute can also be used to improve the quality of search results in search results that are based on the user's linguistic preferences.
spell check
The spellcheck attribute specifies whether the element's content is allowed to be checked for spelling errors. The attribute can take one of the following values:
true - indicates that the content of the element should be checked for spelling errors whenever possible.
false - specifies that the element should not be checked for spelling errors.
The spellcheck attribute is enumerable. This means that an explicit attribute value is required. Adding an attribute without a value is prohibited:
The spellcheck attribute only defines a recommendation to the browser that browsers should not be able to check for spelling errors. Normally, non-editable elements are not checked for errors, even if the attribute is set to true and the browser supports checking.
style
The style attribute is used to add CSS styles to an element. Styles added with the style attribute take precedence over styles located on the element