Some attributes can be used on almost any element. They are called global attributes. These are the ones you will use most often outside of id and class, which have their own lesson next.
title
title adds extra information, which many browsers show as a tooltip when you hover.
<abbr title="HyperText Markup Language">HTML</abbr>
Do not rely on title for important information. Touch screens and keyboards often cannot show tooltips.
lang
lang says what language the content is in. Set it on <html>, and override it on a smaller element when you switch languages.
<p>The French word for book is <span lang="fr">livre</span>.</p>
Screen readers use lang to choose the right pronunciation.
hidden
hidden removes an element from the page until something shows it again.
<p>Always visible.</p>
<p hidden>This paragraph is hidden.</p>
style
style applies CSS directly to one element.
<p style="color: #b84624;">A terracotta paragraph.</p>
This works, but use it sparingly. Styles written in a stylesheet are easier to reuse and change. You will compare the options in Inline CSS.
Other useful globals
| Attribute | Purpose |
|---|---|
tabindex | Controls keyboard focus order |
contenteditable | Lets visitors edit the text |
data-* | Stores custom data for scripts, see Data Attributes |
aria-* | Accessibility information |
Using title for essential text
title is hard to use on a phone. Use a visible label, covered in HTML Labels.