id
Creates one unique identifier. Useful for anchors, labels and JavaScript targets.
Learn id, class, title, hidden, tabindex, lang, dir, style as part of the HTML attribute system: what they configure, where they belong and which mistakes to avoid.
Global
Some attributes are not tied to one special element. They can appear on many elements because they describe identity, language, visibility, focus, styling hooks or small pieces of interface behavior.
Global attributes are powerful because they are everywhere. That also means they should be used with discipline. A messy class name, repeated id or wrong lang value can create problems across CSS, JavaScript, accessibility and SEO.
id, class, title, hidden, tabindex, lang, dir, style. Attributes that can be used on many HTML elements. What belongs here
idCreates one unique identifier. Useful for anchors, labels and JavaScript targets.
classAdds one or more reusable class names for styling and scripting.
titleAdds advisory information. Do not use it as the only explanation.
hiddenRemoves content from view and from most assistive technology until it is revealed.
tabindexChanges keyboard focus order. Useful in rare cases, risky when overused.
styleAdds inline CSS. Handy for demos, usually weak for production code.
Syntax in context
Write the attribute name, then an equals sign and a quoted value. Boolean global attributes such as hidden are different: their presence is the setting.
<section id="pricing" class="content-panel" lang="en"> <h2>Pricing</h2> <p hidden>This note can be revealed later.</p> </section>
Good versus weak
<section id="pricing" class="content-panel" lang="en"> <h2>Pricing</h2> <p hidden>This note can be revealed later.</p> </section>
<section id="box" class="red big nice thing" style="color:red"> <h2 title="Pricing">Pricing</h2> </section>
Rules that matter
An id should appear once on a page. Repeating it breaks anchors and can confuse scripts.
Classes are ideal for styling groups of elements without tying code to one element.
Inline style is hard to override, hard to maintain and usually better moved to CSS.
Many touch users never see title tooltips and screen reader support is inconsistent.
Production thinking
Attributes are small, but they change how an element works. A good attribute can make a link usable, an image understandable, a form easier to complete or a script safer to load.
Global attributes can improve accessibility when used carefully. lang, hidden and tabindex directly affect how people read and move through the page.
In production, treat global attributes as public API for your HTML. CSS, JavaScript, anchors and testing tools may all depend on them.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.