HTML span Tag

HTML <span>Tag: The HTML<span> tag is a generic inline container for inline elements and content. It used to group elements for styling purposes.  And the better way to use it when no other any other semantic element is available. HTML Span tag is very similar to the div tag, but div is a block-level tag and span is an inline tag.

HTML<span>Tag

This HTML span tag supports both the global and the event attributes. The span tag is a paired tag means it has both open(<) and closing (>) tag and it is mandatory to close the tag.

  • used to the grouping of inline-elements.
  • does not make any visual change by itself.
  • span is very similar to the div tag, but div is a block-level tag and span is an inline tag.

Syntax: <span> Text</span>

Browser compatibility



The HTML<span> tag is supported by different types of browsers.

  • Chrome
  • Firefox
  • Opera
  • Safari
  • Internet Explorer

Example:

<!DOCTYPE html>
<html>
<body>
<p>My mother has <span style="color:blue;font-weight:bold">blue</span> eyes and my father has <span style="color:darkolivegreen;font-weight:bold">dark green</span> eyes.</p>
</body>
</html>

Output:

html span tag