HTML5 <span> Tag

The HTML <span> tag is used as a generic inline container for phrasing content, which does not inherently represent anything. It can be used to group elements for styling purposes (using the class or id attributes), or because they share attribute values, such as lang. It should be used only when no other semantic element is appropriate. <span> is very much like a <div> element, but <div> is a block-level element whereas a <span> is an inline element.

The only content permitted inside this element is phrasing content. Both the starting and ending tag are mandatory for this element. The parent of the <span> tag can be any element that accepts phrasing content, or any element that accepts flow content.

Here is an example of using this tag:

<p><span>Some text</span></p>

Attributes

This element only accepts global attributes.

Further Reading

  1. Read more about the HTML <span> element on MDN.
  2. You can also read the HTML <span> tag reference on W3C.

Reader Comments

1. You can register or login to post a comment. Asking readers to register improves the quality of discussion.

2. As a registered user, you will also get to access features like choosing between a light and dark theme or anything else that we might implement in future.

Follow Us For Updates

FacebookTwitterGoogle+
Go To Top