Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<span>

An inline container without meaning: used to style part of a text.

Syntax

<span class="name">Text</span>

Attributes

ParameterTypeDescription
classtextA class used to reach the text from CSS.

Examples

Colouring part of a text:

<style>
  .price { color: green; font-weight: bold; }
</style>
 
<p>Latte — <span class="price">$4.50</span></p>

Notes

<span> does not change how text looks on its own. If the fragment has a meaning, pick a fitting tag: <strong>, <em>, <time>, <mark>. For blocks use <div>.

See also

  • <div> — A block container without meaning: groups elements for styling and layout.
  • class — One or more classes of an element — the main way to reach it from CSS.
  • <strong> — Important text; shown in bold by default.

Related recipes

In the tutorial

  • The box model — What an element consists of in CSS — content, padding, border and margin, sizes, centering and box-sizing.

Thanks for reading!

Donate to the site — we work hard for you.