HTML <span> Tag
Description
The <span> element is a generic inline container in HTML that is used to group and apply styling or scripting to a portion of text or other inline elements without introducing any additional structural meaning. Unlike block-level elements, <span> does not create line breaks and does not inherently affect the layout of the content. It is purely a semantic-neutral container, meaning it carries no intrinsic meaning about the content it wraps.
<span> is most commonly used in combination with CSS and JavaScript. For example, developers can use it to apply styles such as colors, fonts, or text decorations to part of a paragraph, or to target a specific segment of text for scripting purposes, such as highlighting, toggling visibility, or adding interactivity.
Because <span> is inline and semantically neutral, it is ideal for fine-grained control over content presentation. It is often used when a <div> would be inappropriate, as <div> is a block-level element intended for larger structural divisions, whereas <span> works within a line of text.
Example usage (conceptual, not including CSS/JS here):
<p>This is a <span>highlighted</span> word in a sentence.</p>
In this example, the <span> wraps the word "highlighted," allowing developers to style or manipulate it without affecting the rest of the paragraph.
Properties
- Permitted Parents
- Any element that accepts phrasing content, or any element that accepts flow content
- Content
- Inline and text
- Start/End Tags
- Start tag: required, End tag: required
Example
Attributes
None
Global Attributes
The <span> tag also supports the Global Attributes in HTML5
Event Attributes
The <span> tag also supports the Event Attributes in HTML5
Browser Support
The following information will show you the current browser support for the HTML <span> tag. Hover over a browser icon to see the version that first introduced support for this HTML tag.
This tag is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 26th December 2025
