Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

Using the <span> tag to set a style

The <span> tag is similar to the <div> tag, but you use it to change styles within a sentence or within a word, or to create special effects. For example:

<p>The style specification affects 
<span style="font-size: 10pt; color: red">
all the text </span>until the span close tag</p>

You use it to apply a style when you cannot attach the style to an HTML tag.

  • If you use the <span> tags to apply styles, browsers that don't support style sheets won't recognise the tags and any formatting you've applied will be lost.