Global Attributes (id, class, style, title)
Global attributes can be used on almost any HTML element, regardless of its type. Four of the most common ones:
id — a unique identifier for one specific element on the page. No two elements should share the same id.
<div id="main-header">...</div>
class — a reusable label that can be applied to many elements, primarily used to attach shared CSS styles or JavaScript behavior.
<p class="highlight">Important note</p>
<p class="highlight">Another important note</p>
style — applies inline CSS directly to one element. Useful for quick tests, but generally discouraged in real projects since it mixes structure and presentation.
<p style="color: red; font-weight: bold;">Warning text</p>
title — adds a tooltip that appears when the user hovers over the element.
<abbr title="HyperText Markup Language">HTML</abbr>
A practical rule: use id when you mean exactly one element, class when you mean a group of elements that share behavior or style, and reach for style only when nothing else is more appropriate — a linked stylesheet is almost always the better long-term choice.