HTML / HTML Tags

HTML <Span> Tag

Dec 12, 2022
1 min read
HTML span Tag

Definition

A <span> tag is an inline container that can be used to mark up text or other phrasing content elements, such as <abbr>, <b>, <em>, <picture>, and more.

Example

<p>This is some example <span style="color:red">red text</span>.</p>

This is some example red text.

Usage

  • Both the opening and closing tags are required.
  • The <span> element can be styled easily using CSS. You can even group various elements using CSS classes to style multiple elements the same.
  • The <span> element is similar to a <div> in that it has no special or semantic meaning. However, where the <div> is a block-level element, a <span> is an inline element.

Attributes

The <span> element only supports the Global Attributes.

Specification

Browser Support

Desktop

ChromeEdgeFirefoxIEOperaSafari
YesYesYesYesYesYes

Mobile

Android WebviewChrome AndroidFirefox AndroidOpera AndroidiOS SafariSamsung Internet
YesYesYesYesYesYes