9.1. Using the span Element

Sometimes, you want to treat some text in a paragraph, or even a headline, differently from the rest of the text of which it is a part. For example, you might want to change the font, or some font characteristic, such as size or color, of one or two words in the midst of a paragraph. Obviously, you can't create a new paragraph within the existing paragraph without completely messing up the formatting of the page.

That's where the <span> tag comes in. A <span> tag creates an inline collection of text to which styles can be applied. A <span> tag is similar to a <div> tag, but is treated as an inline element by default instead of a block element.

As you might expect, a span element can be connected to an ID or class ...

Get HTML Utopia: Designing Without Tables Using CSS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.