Global Attributes in HTML

In HTML, Global attributes are special features that can be used in almost any HTML element. They provide common functionality that can be applied across different types of elements.

Understanding Global Attributes

Let’s understand this topic with some examples : 

Example 1: id attribute

The `id` attribute uniquely identifies an element on a web page. It’s like giving a specific name to an element so you can easily find and style it with CSS or manipulate it using JavaScript.

				
					<p id="intro">This is an introductory paragraph.</p>

				
			

Example 2: class attribute

The `class` attribute is used to group elements together. You can apply the same styles to multiple elements by assigning them the same class.

				
					<p class="important">This is an important paragraph.</p>
<p class="important">Another important paragraph.</p>
				
			

Example 3: style attribute

The `style` attribute allows you to add inline CSS styles to an element. It’s handy for applying quick styles directly to specific elements.

				
					<p style="color: red; font-size: 18px;">This text is styled!</p>
ss="important">Another important paragraph.</p>
				
			

Global attributes in HTML, like id, class, and style, provide a way to add extra information or functionality to HTML elements. They make it easier to work with and manipulate elements, apply styles consistently, and create more interactive web pages.

Table of Contents

Contact here

Copyright © 2025 Diginode

Made with ❤️ in India