Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

global attributes
html
communitycreator

What are global attributes in HTML?

AKASH BAJWA

Global attributes are common amongst all HTMLHypertext Markup Language elements. These attributes can be applied to any element, even if that element is not specified in the standard documentation.

The table below shows a list of global attributes that can be applied to any HTML element:

List of global attributes

No.

Attribute

Description

1.

accesskey

Provides a shortcut key to activate an element. It must be a single character or a number.


2.

class

Specifies the classes for an element (CSS or Javascript).

3.

contenteditable

Indicates whether or not the element is editable.

4.

data-*

Custom data attributes that allow the exchange of information between HTML and its DOM.

5.

dir

Indicates the text direction in an element.

6.

draggable

Indicates whether or not an element is draggable.

  • true: Represents that the element may be draggable.
  • false: Represents that the element may not be draggable.


7.

enterkeyhint

Hints what action or response should be generated when the enter key is pressed through virtual keyboards.

8.

hidden

Hide the elements of a page that are no longer relevant or available.

9.

id

Unique identifier for an element or tag. It should be distinctive throughout the HTML document.

10.

is

Specifies that a standard HTML tag should behave like a custom built-in element.

11.

itemid

Global, unique identifier of an element or tag.

12.

itemscope

Allocates specific scope about an element to indicate that this block of content is for a specified element. It can be used with itemtype.

13.

lang

Indicates the language for an element.

14.

nonce

A 'number used once' that can be used to check if a fetch request is allowed to proceed to help implement security.

15.

part

A space-separated list of part names of any tag. It helps CSS select style elements to apply effects by the ::part() method in a shadow tree.

16.

slot

The "slot" attribute assigns a slot in a shadow DOM. A shadow tree behaves like any HTML document. It coexists with the document other trees, but it is completely independent. It provides the opportunity to define your own classes and IDs that do not interfere with other tree attributes in the same document.

i.e. name="ID" has same name as class name.

<div class="admin">

 <div class="ID">

   <slot name="ID"></slot>

  </div>

</div>

17.

spellcheck

Indicates whether the text inside an element can be checked for spelling mistakes. It can either be true or false.

18.

style

Defines inline CSS style for an element.

19.

title

Additional information about a tag or an element to provide a basic definition.

20.

translate

Helps to translate the text of an element. It can be set to either `yes` or `no`, to specify if the text is translatable.

RELATED TAGS

global attributes
html
communitycreator
RELATED COURSES

View all Courses

Keep Exploring