Menu

Global Attributes

Global Attributes

You can use global attributes on almost any HTML tag, regardless of what it is. The most common ones are id, class, style, and title.

id gives an element a unique name on the page, used for things like linking to a section or targeting it with CSS or JavaScript.

class works similarly but can be reused across many elements, which is useful for styling groups of things the same way.

There is also a special attribute pattern called data attributes, written as data followed by a hyphen and any name you choose, used to store custom information directly on an element.

<div id="main-banner" class="banner large" data-user-id="204">

  Welcome back!

</div>

Explanation: This div has a unique id, a class for attaching CSS styling, and a custom data attribute holding a user id, which JavaScript could later read to personalize the page. Global attributes like these are what connect HTML to CSS and JavaScript.


HTML Tutorial (From Basics to Implementation)

AP

Abhishek Pati





Get in Touch For Details