The span tag
The span
tag allows you to highlight a piece of text. The tag itself does nothing, but when combined with the attributes class
, id
or style
it allows you to access the text inside it via CSS (for example, to change the color of the text, its size, and so on).
Example
Let's select a piece of text using the span
tag, but leave it the same as normal text (since this span has no CSS styles assigned):
this is <span>text inside span</span>
:
Example
Now let's try to assign a red color to the span
tag using the style
attribute:
this is <span style="color: red;">text inside span</span>,
and this is outside:)
:
See also
-
tag
div
,
which allows you to select a whole group of tags