The Wayback Machine - https://web.archive.org/web/20241002010745/https://www.geeksforgeeks.org/html-global-attributes/
Open In App

HTML Global Attributes

Last Updated : 10 May, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

HTML Global Attributes are attributes that can be used with any HTML element. They include id, class, style, title, lang, tabindex, and others, providing common functionality and enhancing element behavior and presentation across web pages.

List of Global Attributes:

Global Attributes

Description

Example

accesskey It is the keyboard shortcuts to activate/focus specific elements.
Try

autocapitalize It is used to capitalize the text entered/edited by the user automatically.
Try

autofocus The autofocus attribute in HTML is used to specify that the element should get focus when the page loads. It is a boolean attribute.
Try

class It specifies one or more class names for an HTML element.
Try

contenteditable It is used to specify whether the content present in the element is editable or not. When this attribute is not set in an element, this element will inherit from its parent element.
Try

contextmenu It is the id of a <menu> that provide contextmenu for this element.
Try

data-* It can be used to define our own custom data attributes.
Try

dir It is used to specify the text direction of the element content.
Try

draggable It is used to specify whether an element is draggable or not. Links and images are by default draggable.
Try

enterkeyhint It provides a hint on what label or icon to present on a virtual keyword while pressing keys.
Try

hidden It is used to define the visibility of elements. It contains a boolean value. If this attribute is used then browsers will not display elements that have the hidden attribute specified.
Try

id It is a unique identifier that is used to specify the document and used by CSS and JavaScript to perform a certain task for a unique element.
Try

inputmode It is used mainly to provide a hint to browsers on which virtual keyboard configuration to use when editing this element or its contents.
Try

is It specifies that standard HTML behaves as a registered custom built-in element.
Try

itemid It is a global identifier of an item that is unique.
Try

itemprop It adds properties to an item.
Try

itemscope It works with item types to ensure that the HTML contained in a block is about a particular item.
Try

itemtype It specifies the URL vocabulary which is used to define itemprops.
Try

lang It is used to specify the language of the element content. Some examples of languages are en for English, es for Spanish, etc.
Try

nonce It is a cryptographic nonce (“number used once”)  used by a content security policy to check given fetch allowed to proceed or not.
part It is a space-separated list of the part names of the element.
Try

slot It is used to assign a slot in a shadow DOM shadow tree to an element.
Try

spellcheck The Spell Check feature in HTML is used to detect grammatical or spelling mistakes in the text fields.
Try

style Style in HTML are basically rules that describe how a document will be presented in a browser.
Try

tabindex It is used to specify the tab order of an element. It is used when the tab button is used for navigating.
Try

title It is used to define the title of an HTML document, sets the title in the browser toolbar, and provides the title for the web page when it is added to favorites.
Try

translate The translate attribute in HTML is used to specify whether the content of an element is translated or not.
Try



Previous Article
Next Article

Similar Reads

How to remove all attributes of an HTML element using jQuery ?
In this article, we will see how to remove all attributes of an HTML element using jQuery. To remove all attributes of elements, we use the removeAttributeNode() method and .removeAllAttributes(). Syntax: $.fn.removeAllAttributes = function() { return this.each(function() { $.each(this.attributes, function() { this.ownerElement.removeAttributeNode(
1 min read
HTML DOM attributes Property
The attributes property in HTML DOM returns the group of node attributes specified by NamedNodeMap objects. The NamedNodeMap object represents the collection of attribute objects and can be accessed by index number. The index number starts at 0. Syntax: node.attributes Return Value: It returns the NamedNodeMap object which is the collection of node
2 min read
Difference between 'hidden' and 'aria-hidden' attributes in HTML
The HyperText Markup Language (HTML) is a powerful web development tool combined with CSS and JavaScript. Apart from these, HTML also uses Accessible Rich Internet Application (ARIA) to make web content affable for a person with disabilities. Although ARIA is beneficial, there are keywords common to both HTML and ARIA, creating perplexity among ama
2 min read
Why are dashes preferred for CSS selectors / HTML attributes ?
CSS is a hyphen-delimited syntax language which means while writing HTML attributes we can use hyphen(-). Example: font-size, line-height, background-color, etc... There are various reasons to preferring hyphen(-): In CSS, one can use underscore(_) instead of hyphen(-) for CSS selectors(class, id, span, ...), but preference is given based on its ea
2 min read
What is the difference between properties and attributes in HTML?
HTML is the standard language for creating documents that are intended to be displayed on web browsers. It is very usual to get confused with attributes and properties while performing DOM object manipulation in JavaScript. Before learning about the differences, let us first define the Document Object Model. DOM: It is the acronym for the Document
4 min read
How to add attributes to an HTML element in jQuery?
Given an HTML document containing some elements and the task is to add the attributes to the HTML elements. Approach: Given an HTML document containing <label>, <input> and <button> elements. The <input> element contains the type and id attribute. When user click on the button, the jQuery function is called. We use $(selecto
1 min read
Placeholder vs Value Attributes in HTML
Placeholder Attribute:The placeholder attribute specifies a short hint that describes the expected value of an input field/textarea. The short hint is revealed in the field before the user enters a value. It is just a temporary hint and has nothing to do with logical executions in the backend. Syntax: <input placeholder = "text"> <textarea
3 min read
What are HTML tags & Attributes mandatory for a good Web page in SEO ?
Search engine optimization (SEO) is the process that involves enhancing the visibility of a website on search engines. This is achieved by increasing the website's ranking on search engine results pages, such as Google. The higher the website appears on these pages, the more likely it is to receive a larger volume of traffic. SEO involves understan
5 min read
Attributes that work differently between React and HTML
There is a minor difference between React(JSX) and HTML attributes. Like for example, the HTML attributes like class and for are replaced with className and htmlFor in React. There are a number of attributes that work differently between React and HTML. Grammar in JSX is mostly the same as in HTML, but there are subtle differences to watch out for.
3 min read
What is the purpose of the HTML "aria-*" attributes?
The HTML "aria-*" attributes, part of WAI-ARIA (Web Accessibility Initiative - Accessible Rich Internet Applications), are used to enhance the accessibility of web content. These attributes provide additional information to assistive technologies, such as screen readers, in interpreting and presenting content to users with disabilities. Syntax<b
1 min read
Difference Between Async & Defer Attributes in HTML
The async and defer attributes on a <script> tag in HTML are used to control the loading and execution behavior of external JavaScript files. While both of them have their own set of advantages and disadvantages, one should know which attribute is used at the right time. The difference between the async and defer attributes in HTML are as fol
5 min read
What are HTML Attributes ?
HTML attributes are the entities that provide the extra information about the tags. Attributes are specified using name and value pair. Some HTML tags are used without attributes while for some tags it's important to specify attributes along with them. In paired tags attributes are specified in the opening tag. The value of the attribute is specifi
3 min read
How to Create Optional HTML attributes with Razor View Engine ?
It's common practice in web development to dynamically create HTML components with optional attributes in response to specific criteria. When working with ASP.NET Core apps and the Razor view engine, this necessity is especially prevalent. With Razor, users can easily generate dynamic web content by integrating C# code with HTML markup in an easy a
3 min read
HTML Event Attributes Reference
Events are actions that happen in the browser when the user does something For example when users click on the mouse or type something on the keyboard. HTML Event Attributes: In HTML, we can use event actions on the browser, and with the help of the event, the user responds to the system. Event Attributes can be used with HTML elements to perform v
5 min read
How to use ARIA Attributes to Enhance Accessibility in HTML ?
Accessibility is a fundamental aspect of web development, ensuring that all users, regardless of ability, can access and interact with online content. HTML provides various features to improve accessibility, and one powerful tool is ARIA (Accessible Rich Internet Applications) attributes. ARIA attributes extend HTML semantics, providing additional
2 min read
How to Add and Remove HTML Attributes with jQuery?
Using jQuery, we can dynamically add and remove HTML attributes such as placeholder, style, and more to enhance the interactivity and functionality of web elements based on user actions. We will explore two different approaches to adding and removing HTML attributes with jQuery. Below are the possible approaches to add and remove HTML attributes wi
2 min read
Tags vs Elements vs Attributes in HTML
In HTML, tags represent the structural components of a document, such as <h1> for headings. Elements are formed by tags and encompass both the opening and closing tags along with the content. Attributes provide additional information or properties to elements, enhancing their functionality or appearance. Table of Content HTML Tags: HTML eleme
2 min read
Difference between "blank" and "_blank" target attributes in HTML
If you have ever noticed on the website that few links got opened either in a new tab or in a new window or sometimes, it might also happen that in some websites, click on the link, for the first time, it will open in a new tab & that particular open tab will update & reused every time whenever we click to the link. Both these scenarios can
3 min read
HTML Attributes
HTML attributes provide additional information about elements within an HTML document. Every HTML element can have attributes. Attributes are always defined in the start tag. They are specified using a name/value pair format, where the attribute name defines the property, and its value provides specific details, like name="value". These attributes
6 min read
HTML data-* Attributes
The HTML data-* attribute allows storing custom data for elements, enhancing interactivity in web applications through JavaScript without server-side involvement or AJAX calls. Syntax <li data-book-author="Rabindra Nath Tagore"> Gitanjali </li>The data-* attributes can be used to define our own custom data attributes. It stores custom d
3 min read
HTML Attributes Complete Reference
HTML attributes are special words placed inside the opening tags of HTML elements to define their characteristics. Each attribute consists of two parts: the attribute name and its value, separated by an equal sign (=) and enclosed in double quotes (" "). Syntax of HTML Attribute<tag_name attribute_name="value"> Contents... </tag_name>Ov
7 min read
Difference between id and class Attributes in HTML
The id and class attributes in HTML are used for element identification and styling. The id attribute uniquely identifies a single element, while the class attribute can be applied to multiple elements. Both are essential for CSS styling and JavaScript manipulation. HTML id AttributeThe id attribute is a unique identifier that is used to specify th
3 min read
jQuery | Set Content and Attributes
Set Content: It is used to set the content using jQuery. The following methods are used to set the content which are listed below: text(): It is used to set or return the text content of selected elements. html(): It is used to set or return the innerHTML content of the selected element. val(): This parameter is used to set or return the value of a
2 min read
jQuery | Get Content and Attributes
Get Content: In order to get the content of DOM object, there are three simple methods.jQuery methods for DOM manipulation which are listed below: text(): It is used to set or return the text content of selected elements. html(): It is used to set or return the content of selected elements including HTML markup. val(): It is used to set or return t
2 min read
How to conditionally add attributes to React components?
We can conditionally add attributes to React components with the following approaches: Approach 1: Evidently, with some attributes, React is smart enough to omit the attribute if the value you pass to it is not truthy. For example: state= { disabled: false, required: true } return ( <input type="text" disabled={disabled} required={required} /
2 min read
XML | Attributes
Prerequisite: XML | BasicsThe XML attribute is a part of an XML element. The addition of attribute in XML element gives more precise properties of the element i.e, it enhances the properties of the XML element.Syntax: <element_name attribute1 attribute2 ... > Contents... </element_name> In the above syntax element_name is the name of an
3 min read
Blaze UI Divider Attributes
Blaze UI is a user interface toolkit that provides a strong foundation and many components to building maintainable and scalable websites efficiently. All the features of Blaze UI rely on native browser features so it does not require an additional framework or library to work. In this article, we will be seeing Blaze UI Divider Attributes. The Div
3 min read
PHP | SimpleXMLElement attributes() Function
Pre-requisite: Read XML BasicsThe SimpleXMLElement::attributes() function is an inbuilt function in PHP which is used to retrieve the attributes and its value from an XML tag in a SimpleXML object. Syntax: SimpleXMLElement SimpleXMLElement::attributes( $namespace, $is_prefix ) Parameter: This function accepts two parameters as mentioned above and d
2 min read
Copy all the attributes of one element and apply them to another with JavaScript
The task is to copy all attributes of one element and apply them to another with the help of JavaScript. Here 2 approaches are discussed. Approach 1: Select both elements(target and source element).Get the properties of source element by using el.prop('attributes') method.Use .each() method on each object property and set that property to the targe
2 min read
What are these attributes `aria-labelledby` and `aria-hidden` ?
The term, ARIA with attributes such as aria-labelledby and aria-hidden stands for Accessible Rich Internet Applications. These are the set of standards and guidelines that makes web applications more accessible to people with disabilities. This is used in the interactive content in an HTML document such as error messages, progress bars, progressive
3 min read