
Figure 3.16. Applying the "fun" class to two specific words
Note: Don't Throw (Needless) spans into the Works
The span element is nearly always used with a class attribute. There is not normally a good reason to apply a span element to your XHTML on its own, although you may see some web sites that do so.
Before you apply a span to any given element on your web page, take a moment to think about whether there's another element that's better suited to the task. For example, you should not use something like this:
<p>Do it <span class="shouty">now</span>!</p>
A more appropriate choice would be to use the strong element:
<p>Do it <strong>now</strong>!</p>
Think of the meaning of what you're writing, and aim for an XHTML element that suits the purpose. Other examples might be em, cite, and blockquote..
Summary
It's been another busy chapter, but my, how our site's blossoming! A chapter or two ago, we hadn't even built a web page, but now we're at the stage where we know how to apply a (virtual) lick of paint to any type of XHTML element on a page, to a specific section of a web page depending on its id, or to arbitrary portions of a page -- sometimes in several different places -- using class selectors.
The web site is starting to look a little more colorful, but the layout is still fairly basic. In the next chapter, we'll look at how it's possible to change the layout of elements on a page -- their position, shape, size, and more -- using CSS.
Styling text? Been there, done that. Let's move to the next level! Build Your Own Web Site The Right Way Using HTML & CSS [32]. After the next chapter, on CSS, we explore the tasks of using images on your web site, the appropriate use of tables, building forms that promote user interaction, publishing your site to the Web, adding a blog to your site, and hooking up to ready-made tools like statistics packages, search functions, and discussion forums that you can apply to your site. As I mentioned, the book comes with a complete code archive, so you can apply the files we use in the book straight into your own sites (makes life easy, eh?).
Share and Enjoy: