The <span> Element

Span elements provide a simple mechanism for inline formatting of text. In its simplest form HTML for a span bears the form

<span>Formatted text</span>

By itself, such a span specification would be practically useless. In order to use spans one would, at the very least, do one of the following

Spans are very amenable to CSS styling and share the following attributes in common with other HTML elements

Using spans to format inline text is extremely useful. However, the need to specify a class attribute means that one ends up adding several bytes of text per span. On this site we reduce this burden by identifying the most commonly used inline formatting and simply redefining some of the more obscure intrinsic HTML styles such as <addr>, <big> etc. This results in more compact web pages. There is a downside to using such a strategy - screen reader software may get quite confused by inappropriately used restyled intrinsic tags. This is a risk you must assess for the site you are developing and make a decision as to whether it is worthwhile.

Jump To...

Colophon