# abbr, q, time & span

> Four inline elements that cover abbreviations, inline quotations, machine-readable dates, and the generic style hook for everything else.

Subject: HTML | Lesson 13 of 42 | 5 min read
Interactive lesson: https://codewithanimation.in/html/abbr-q-time-and-span
Previous: [Edits & Computer Text](https://codewithanimation.in/html/edits-and-computer-text.md) | Next: [The Anchor Element & href](https://codewithanimation.in/html/anchor-and-href.md)

## What they are

`<abbr>` marks an abbreviation or acronym. Its `title` attribute holds the expanded form. Browsers traditionally render a dotted underline and display the expansion in a tooltip on hover. `<q>` marks an inline quotation. The browser supplies opening and closing quotation marks automatically, in the correct style for the page's language. Never add manual quote characters inside `<q>`.

`<time>` marks a date, time, or duration. The human-readable text inside the element can be anything, but the `datetime` attribute holds an ISO 8601 value that machines can parse reliably. `<span>` is the generic inline container with no semantic meaning of its own, useful only when you attach a class, id, or data attribute to hook into CSS or JavaScript.

## Why it matters

`<abbr>` makes abbreviations legible without cluttering the prose. A reader hovering over CSS sees "Cascading Style Sheets" rather than having to look it up. That said, the tooltip is not reliably exposed by screen readers, so the convention is to write the expansion out the first time it appears in a document and then use the abbreviation freely after that.

`<time>` solves a long-standing problem: human date formats are wildly inconsistent across cultures. "06/07/26" means three different dates depending on locale. The `datetime` attribute pins the unambiguous machine value alongside whatever natural-language form you choose for the reader. Search engines use `<time>` to index event dates, and calendar apps can parse it directly.

## How it works

Add `title` to `<abbr>` with the full expansion. The text content should be the abbreviation itself: `<abbr title="Cascading Style Sheets">CSS</abbr>`. You can also style the dotted underline or remove it with CSS `text-decoration`.

`<q>` wraps the quoted text only, with no extra punctuation. The browser inserts the right quote characters for the current `lang` attribute. A `cite` attribute can hold the URL of the original source, though it is invisible to readers; if you want a visible citation, place a `<cite>` element outside the `<q>` block.

In `<time>`, the `datetime` value follows ISO 8601: `2026-06-26` for a date, `14:30` for a time, `PT2H30M` for a duration of two hours and thirty minutes. The visible text is completely free: `<time datetime="2026-06-26">last Thursday</time>` is valid and useful. Use `<span>` only after confirming none of the semantic elements fit. It exists for cases where you genuinely need a hook with no attached meaning.

## Common mistake: Adding manual quote marks inside <q>

Writing `<q>"Hello"</q>` produces doubled quotation marks: the browser adds its own outer quotes and your manual inner quotes both appear. Let the browser do its job: write `<q>Hello</q>` and the correct locale-aware quotes appear automatically. If you need a specific quote style, override it with CSS `quotes`.

## Tip: Write the expansion out the first time, then use <abbr>

Screen reader support for `<abbr>` titles varies and is not something you can rely on. The accessible pattern is to spell out the term the first time: "Cascading Style Sheets (CSS)" and then use `<abbr title="Cascading Style Sheets">CSS</abbr>` for every subsequent occurrence. Readers who do not need the expansion skip past it; those who do have it in text rather than in a tooltip.

## Try it: Try it

See `<abbr>` with its dotted underline and expansion, `<q>` adding quote marks automatically, and `<time>` pairing a human date with its machine `datetime` value.

The animation is on the lesson page and is not part of this text version: https://codewithanimation.in/html/abbr-q-time-and-span

## Check yourself

### Question 1

You write: <q>"She said hello."</q>. What does the browser render?

- A. Doubled quotes: ""She said hello.""
- B. Normal quotes: "She said hello."
- C. No quotes: She said hello.

Correct answer: A

`<q>` inserts opening and closing quotation marks automatically. Manual quote characters inside the element produce a doubled set. Write the text without manual quotes and let the browser supply them.

- Why not B: The browser adds its own quote marks around the <q> content. Your manual quotes stay, producing a doubled result.
- Why not C: <q> always adds quotes. The issue here is the extra manual quotes inside, which produce a doubled result.

### Question 2

What is the purpose of the datetime attribute on <time>?

- A. It holds a machine-readable ISO 8601 value while the element text stays human-friendly
- B. It controls how the date is displayed to the reader
- C. It is required for the element to be valid

Correct answer: A

`datetime` decouples the machine value from the human text. The reader sees "last Thursday"; a search engine or calendar app reads `2026-06-19`. Both get the form that works for them.

- Why not B: The display text is whatever you write between the tags. datetime is only for machines: search engines, calendar apps, and screen readers.
- Why not C: datetime is optional. Without it, the element's text content must itself be a valid date-or-time string, but datetime is never mandatory.

### Question 3

When is <span> the right element to use?

- A. When you need an inline hook for CSS or JavaScript and no semantic element fits
- B. Whenever you want to apply a color to a word
- C. <span> should be avoided; always use a semantic element instead

Correct answer: A

`<span>` exists for the cases where you need an inline container but none of the semantic inline elements apply. Check the semantic options first; if none fits, `<span>` is the right tool.

- Why not B: First check whether a semantic element (<em>, <strong>, <mark>, <abbr>...) fits. Only reach for <span> when none of them is appropriate.
- Why not C: <span> is legitimate and necessary for cases where no semantic element fits. It is a last resort, not forbidden.

## Remember this

- `<abbr title="...">` provides an expansion on hover; write the full term out the first time for accessibility.
- `<q>` adds locale-aware quotation marks automatically; never add manual quotes inside it.
- `<time datetime="ISO-8601">` gives machines an unambiguous date while the text can be any human form.
- `<span>` has no semantic meaning; use it only when you need an inline hook and no semantic element fits.
