<span>
An inline container without meaning: used to style part of a text.
Syntax
<span class="name">Text</span>Attributes
| Parameter | Type | Description |
|---|---|---|
| class | text | A 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
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.