March 26, 2007

Marking Up Book Titles Semanticly

When you think of marking up a book title, the first thing you might be thinking about is styling the text in italics. Simple enough.

<em>Practical C Programming</em>

That seems to work, but em renders as emphasized text. Do we really want to emphasize a book title?

According to the Modern Language Association (MLA) guidelines and the Chicago Manual of Style, book titles may be italicized or underlined. Perhaps we could have the book title underlined? It’s probably not a good idea because it would interfere with links which are generally (and always by default) underlined. So let’s try something else.

We’re trying really hard to keep content and style separated. We could use CSS and wrap the book title with span tags.

<span class="book">Practical C Programming</span>
span.book { font-style: italic; }

That sounds good, but if we disable the stylesheet, the italics disappear. Then the book title is like everything else.

If we don’t use em we could revert to using i. Most people wouldn’t even consider this, but I did. The i is not deprecated. But then again, we’re trying really hard to keep content and style separate.

When I first learned how to use cite, I assumed it was blockquote’s “sidecar”. It could also be q’s for that matter. But if you look at Dan’s discussion about titles, you will see some good points about why cite should be used. Take a look at the HTML specification too. When your content “contains a citation or a reference to other sources” you should use cite. Think about that—“a reference to other sources”. Wouldn’t you consider me talking about a book as being another source besides this article? It makes sense.

<cite>Practical C Programming</cite>

How would you mark up a book title?

Posted in: