demosthenes.info

I’m Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with , and . To receive more information, including news, updates, and tips, you should follow me on Twitter or add me on Google+.

web developer guide

my books

Book cover of Pro CSS3 AnimationPro CSS3 Animation, Apress, 2013

my projects

tipster.ioAutomatically provides local tipping customs and percentages for services anywhere.

The span tag

html / tags

Estimated. reading time: 55 seconds

<span> is the second-most commonly misunderstood tag in the lexicon, after <div>. A useful way to think of <span> is this: it is an inline tag that is the liferaft of HTML, used only after every other possible tag has been eliminated. There are almost always other, better options.

The reason <span> is employed as a last resort is that it lacks any semantic value: there’s no telling what the content wrapped by <span> represents. In addition, <span> is entirely useless without some attached CSS: applied by itself, it makes no difference at all to presentation. A combination of both factors relegates <span> to rare, considered and careful use in a site.

A typical use of <span> is within a block element, to wrap content that cannot otherwise be reached via . For example:

<p>In this paragraph, I want a particular word to be treated
<span class="special">differently<span> for whatever reason.</p>

Again, we should have eliminated all other possibilities before applying <span>, rejecting inline semantic markup like <dfn> and <abbr>, <em> and <strong>, all of which can have CSS applied to them.