HTML Global Attributes

HTML Global Attributes

Global Attributes are used to refer to attributes, which are used on any HTML element. These attributes are common for all elements in HTML. However, some attributes have no effect on some elements. For instance, the attribute spellcheck won’t affect the behavior or semantic of a paragraph, the same way the lang attribute will have no effect on an element without content.

You can find all Global Attributes and their explanations below:

AttributesDescriptionValueSyntax
accesskeyGenerates a keyboard shortcut for the element.The way of accessing the shortcut key varies in combination with ALT, CTRL, ALT+SHIFT or CTRL+ALT depending on the browser.character<element accesskey=“character”>
classAdds one or more class names for an element. When used with style sheets, it tells the browser, which classes are supposed to assign properties to the element.classname<element class=“classname”>
contenteditableSpecifies whether the content of the element is editable or not.With the “true” value the content of the element will be editable, with the “false” value (default value) the content won’t be editable.truefalse<element contenteditable=“true
contextmenuIs used to create a context menu for the element, and it is shown when the user right clicks on the element.Is not used in HTML 4.01.menu_id<element contextmenu=“menu_id”>
dataAllows exchanging private information between HTML and its DOM representation. It allows embedding custom data attributes on all HTML elements.Is not used in HTML 4.01.somevalue<element data-*=“somevalue”>
dirDefines text direction for contents within the element. It is useful for inserting a piece of content with different text direction to the document, like when text in Arabic, Hebrew, or other language.rtlltrauto<element dir=“ltr
draggableDefines, if an element is draggable or not. When “true” value is used, the browser will allow the user to drag this element, when “false” value is used, dragging capabilities won’t be provided.Is not used in HTML 4.01.truefalseauto<element draggable=“true
dropzoneDefines a dragged data is copied, moved or linked after it is dropped. If none of the values are present, the “copy” value is implied by default.Is not used in HTML 4.01.copymovelink<element dropzone=“copy
hiddenWhen present, it defines an element is not yet or no longer relevant. Browsers will hide the elements when the hidden attribute is specified.Is not used in HTML 4.01.-<element hidden>
idDefines a unique id for the element. Identifiers must be at least one character long and should not present space characters.id<element id=“id”>
langDefines the content language of the element. For this purpose lang or hreflang language attributes are generally used. See all the language codes here.language_code<element lang=“language_code”>
spellcheckDefines if an element may be checked for spelling errors or not. When “true” value is set or the empty string (””), browsers will commonly underline misspelled words in red and provide alternatives in a context menu. When “false” value is set, browsers will avoid checking the element’s content for spelling errors.Is not used in HTML 4.01.truefalse<element spellcheck=“true
styleDefines the CSS style for an element. In contrast to the class attribute, this attribute is considered to be the “inline” way of applying style properties.style_definitions<element style=“style_definitions”>
tabindexDefines tabbing order for an element (when the “tab” button is used for navigating). If the value is negative, the element will be excluded from the tabbing navigation.number<element tabindex=“number”>
titleIs used to put extra information for the element. Browsers generally show this information in a “tool tip” text (a small box of text).text<element title=“text”>
translateDefines if the content of an element must be translated or not. When “yes” value is set or the empty string (””), browsers will regularly translate all texts in the element, when “false” value is set, browsers will exclude the element in the translation process.Is not used in HTML 4.01.yesno<element translate=“yes


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部