Sign in Registration
ruen

What is an attribute in HTML, what are the global attributes

HTML quite a lot all kinds of elements and they can have different attributes. What is an attribute in HTML ? This is an additional entry within an opening tag of the form key - values. With the help of attributes, you can give a tag a completely new functionality, change an existing one, etc. It is simply necessary to specify some attributes, otherwise the tag loses its essence without them.

html-attributes

Global Attributes in HTML are attributes that can be applied to almost all elements:

  • accesskey - provides a hint for creating a keyboard shortcut for an element;
  • class - allows you to specify a class or classes for an element, which can then be used in CSS and JavaScript;
  • contenteditable - allows you to make the content of the element editable;
  • contextmenu - here you should specify the id tag menu , which is used as the context menu for this element;
  • data- * - defines a group of attributes called user data attributes;
  • dir is an attribute that indicates the direction of text in an element. Possible values: ltr, rtl, auto ;
  • draggable - an attribute that indicates whether the element can be dragged with a mouse or other input device;
  • dropzone is an attribute indicating the types of content that can be dropped onto an element. Possible values: copy, move, link ;
  • hidden - allows you to hide the element;
  • id - sets the identifier for the element;
  • item * is a set of attributes that can be used to define microdata: itemid, itemprop, itemref, itemscope, itemtype ;
  • lang - sets the document language;
  • spellcheck - allows you to control how the content of an element is checked for errors;
  • style - contains a description of CSS styles, it is recommended to define styles in a separate file;
  • tabindex is a numeric attribute indicating whether an element can receive focus;
  • title - contains text that is shown as a tooltip when you hover over an element;
  • translate is an attribute used to indicate whether the attribute values ​​of an element and its text content should be translated when the page is localized.

In addition to the main attributes, you may need to use additional global attributes:

  • xml: lang and xml: base - left over from the XHTML specification, retained for compatibility reasons;
  • aria- * - attributes that are used to improve the accessibility of the site for people with different health abilities;
  • event handler attributes: onabort, onautocomplete, onautocompleteerror, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, onclose, oncontextmenu, oncuechange, ondblclick, ondrag, ondragend, ondragitraenter, ondragart ondrop, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmausemove, onmouseoutouse, onmouseheover onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onsort, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting .

As you can see, using attributes is easy, but it's worth paying attention to browser support. Global attributes are supported by almost all browsers, but there may be exceptions, so it's best to test them for each specific browser.

Thus, we examined what is an attribute in HTML and what are the global attributes in this language.

Comments (0)
For commenting sign in or register.

Latest articles

Popular sections

Eqsash (Tools)

Android app - VK LAST USER ID, отучитель от зависимости и т.д.:
Available on Google Play

Amessage (Communication)

Login to the web version
Android app:
Available on Google Play

Share this

Subscribe to

YouTube

Books

IT notes - In simple language about the most necessary things (HTML, CSS, JavaScript, PHP, databases, Drupal, Bitrix, SEO, domains, security and more), PDF, 500 p.