HTML <span> inline span Tag Reference

The span HTML tag means inline span, and is used to apply style to a section of text without breaking the flow of the document.

Use it when you want to apply some styles to a portion of content without affecting the layout in any way.

The <span> HTML/xHTML tag

The <span> inline span tag defines content as 'inline', which means it will go with the flow of the document, as opposed to the <div> tag, which breaks the flow of the document.

It doesn't actually do anything to the content itself, but is used as a 'style hook', allowing you to apply different styles to sections of text within a document.

It's valid in all current versions of HTML and xHTML, and it should always have a closing </span> tag.

When to use the <span> tag (semantic use)

The <span> tag should be used to style sections of text for which there is no appropriate existing HTML tag. For example, you might want to have any prices in a paragraph of text coloured red. There is no <price> tag, so you can simply use the <span> tag with a classname and then use CSS to change the font colour (see example)

Example of <span> tag use

<p>

On sale now for only <span class="price">£15.00</span>

</p>