The span element
The <span>
tag on its own doesn't represent anything or give the content inside it any special meaning. This element is a generic inline container — you can use it to separate parts of text from others and modify it using various attributes.
For example, if you want to make a part of the text blue without adding any particular meaning, use the <span>
tag with the attribute style
and set the color to blue
, like in the example above. But it's more than just about style. Another example of the tag's versatility would be to use the attribute lang
to set a different language to a part of the text and ensure that words written in a language other than the default are displayed correctly.