English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <span> tag

The HTML <span> element is a general inline content container for phrase content and does not have any special semantics. It can be used to group elements to achieve a certain styling intent (by using class or Id attributes), or these elements have common attributes, such as lang. It should be used only when there are no other appropriate semantic elements. The <span> element is similar to the <div> element, but the <div> is a block element while the <span> is an inline element .

Online Example

Use the <span> element to color part of the text:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)<//title> 
</head>
<body>
<p>What you see here is <span style="color:blue;font-weight:bold">blue<//span> the sky, and <span style="color:green;font-weight:bold">green</span> grass.</p>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the <span> tag.

Definition and Usage of Tags

The <span> tag is used to combine inline elements within a document.

The <span> tag does not have a fixed format. It only produces visual changes when styles are applied to it. If no style is applied to <span>, the text within the <span> element will not have any visual difference from other text.

The <span> tag provides a way to isolate a part of the text or a part of the document.

Tips and Notes

Tip:The text enclosed by <span> elements in HTML, you can define its style using CSS, or manipulate it with JavaScript.

HTML 4.01 and HTML5Differences between

N/A.

Global Attributes

Support for <span> tag Global Attributes of HTML.

Event Attributes

Support for <span> tag HTML Event Attributes.