HTML span tag

<span> tag does not have special meaning but it represents its content or child elements. It is an inline element. It can style a piece of text and make annotations.

<p>That text was <span class="span">designed</span> in a stylish way.</p>

That text was designed in a stylish way.

Tag Uses

Specific uses of <span> tag

To make annotations in a paragraph of text.

title attribute

span tag supports the title attribute. Title attribute can be applied on a piece of text.

<p>The title can be written for the text. <span title="cascading stylesheet">CSS</span> is the abbreviatio of cascading stylesheet.</p>

lang attribute

If a small piece of text is of different language in English language then span can be used to specify the type of language.For example,

<p>The title can be written for the text. <span lang="ar">سی ایس ایس</span> is the abbreviatio of cascading stylesheet.</p>

class attribute

class attribute is also applicable on the span element. It can annotate a piece of text.

style attribute

style attribute applies CSS properties to style the content of span elements.

<p>style attribute applies inline CSS properties to <span style="background-color:red; color:white; border:1px; padding:4px;">make annotations</span>.</p>

Tag omission

Both starting and ending tags are necessary for the span element.

Global Attributes

Some of the global attributes are given below. Span tag is useful when used with global attributes.

Was this article helpful?