The <span> element is a generic inline container for phrasing content. Alone it does not change meaning. Use it to group text for styling ( class / id), scripting, or shared attributes such as lang.
Prefer a semantic tag when it fits — <strong>, <em>, <mark>, <code>, and so on. For a generic block wrapper, use <div> instead.
Baseline · Widely available.
Not deprecated. Stable across browsers since about July 2015 (and much earlier in practice).
Last resort for meaning.
Use <span> only when no other phrasing element is appropriate. Do not wrap every word “just in case.”
Syntax
HTML Syntax
syntax.html
<span>phrasing content</span>
Both start and end tags are required. Content must be phrasing content (text and inline elements).
Reference
Attributes
<span> has no element-specific attributes. These globals are the ones you will use most:
Keep the sentence in the page language (here, English).
Wrap the Latin words in <span lang="la">.
Assistive tech and spellcheckers can treat that phrase correctly.
No visual change required — lang is about language, not color.
Example 3 — Prefer Semantic Tags
Do not fake importance or emphasis with a styled span.
HTML
<!-- Prefer -->
<p><strong>Warning:</strong> save your work.</p>
<p>Press <em>Submit</em> when ready.</p>
<!-- Avoid for meaning -->
<p><span class="bold">Warning:</span> save your work.</p>
Use span inside sentences and other phrasing content.
Use div to group blocks (headings, paragraphs, layouts).
Default CSS:span is inline; div is block.
Neither adds meaning — both are generic hooks.
Edge Cases & Pitfalls
Most mistakes overuse span or replace semantic tags with classes.
semantics
Not a bold / italic substitute
Importance and emphasis belong on strong / em (or b / i when those meanings fit), not on a styled span alone.
bloat
Do not wrap everything
Extra spans make HTML harder to read and maintain. Wrap only what needs a hook.
vs div
Wrong display model
Putting block layouts inside span fights the inline box model. Use div (or a semantic sectioning element) for blocks.
a11y
Class names are not roles
class="button" on a span is not a real control. Use <button> or a proper link.
valid
Phrasing content only
Do not nest paragraphs or other flow-only blocks inside span.
Compatibility
Browser Support
The <span> element is core HTML phrasing content in every major browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<span>
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera all support span as a generic inline container with no default meaning.
99%Global support (approx.)
Google ChromeAll
Full support
Mozilla FirefoxAll
Full support
Apple SafariAll
Full support
Microsoft EdgeAll
Full support
OperaAll
Full support
Samsung InternetAll
Full support
Internet ExplorerAll
Supported
<span>Universally supported
Bottom line: Safe to use everywhere as an inline hook. Prefer semantic tags whenever the text has meaning beyond styling.
Remember
Key Takeaways
Role:<span> is a meaning-free inline wrapper for phrasing content.
Hooks: use class, id, or lang when you need a target.
vs div: span = inline; div = block/flow container.
Prefer semantic tags for importance, emphasis, code, and marks.
One line: wrap inline text with <span> only when you need a hook and no better element fits.
UA style
Default CSS Settings
Browsers treat span as an inline box with no special look:
default.css
span {
display: inline;
}
Colors, weights, and backgrounds come entirely from your CSS.
Frequently Asked Questions
The span element is a generic inline container for phrasing content. It has no meaning by itself. Use it to group text for CSS, scripting, or shared attributes such as lang when no semantic tag fits better.
No. span only supports the Global Attributes in HTML (such as class, id, and lang).
span is inline (phrasing content) and sits in the text flow. div is a block-level flow container that typically starts on a new line.
No. Prefer strong for importance and em for stress emphasis. Use span when you only need a styling or scripting hook without that meaning.
By default span has no corresponding ARIA role (generic). It does not announce a landmark. Prefer semantic elements when assistive tech should recognize structure or meaning.
When you need to wrap a phrase for class/id/lang (or similar) and no better element exists — for example coloring ingredient names, or marking a short foreign phrase with lang.