Semantics vs bold and italics

In his article When Semantic Markup Goes Bad, Matthew Thomas writes about why always replacing <i> and <b> with <em> and <strong> is bad, which is absolutely correct. Instead, he suggests using <i> and <b> in some situations. But doing so will prevent the separation of content from presentation, something that a lot of people are trying hard to achieve by using XHTML and CSS instead of presentational markup.

It would be nice if there was a semantic XHTML element for every markup situation, but there isn’t. You will run into situations when what you are marking up doesn’t have a perfectly matching XHTML element.

So, what is the best thing to do in those situations? Using <em> or <strong> will add emphasis to the text, and a screen reader may pronounce those words differently. Is that what you want? Try reading the sentence out loud. Does it make sense to emphasize the words you want displayed in italics or bold?

Some suggest using <span> elements, others say that <i> and <b> are the way to go when XHTML doesn’t have a suitable semantic element. Matt May, James Craig, and Lachlan Cannon are in the <span> camp, and Matthew Thomas has posted his reply to them in When semantic coders go bad.

I’m not going to suggest what to do. I think it will depend on the circumstances which method is the most correct (or the least wrong). What I believe is even more important than what you actually decide to use is that you stop to think about it, and make an effort to make your markup as semantic as possible.

Posted on May 9, 2004 in (X)HTML, Accessibility, Web Standards

Comments

  1. Separating content and presentation is a means to an end, and not an end in itself. The ends are (1) easier redesign (you need to change much less code), (2) lower bandwidth (through non-repeated code, and CSS being cached on subsequent pages), and (3) adaptability to different output devices (e.g. speech browsers).

    For (1), b/i and span are exactly equal (you can use a class with both). For (2), span is 100% worse (no caching benefit, and the tags combined are 12 characters vs. 6 characters). And for (3), span is much worse (since it doesn’t work in browsers ignoring CSS, and it works in very few browsers if you’re styling lang instead of class).

    Anyway, good on you for at least thinking about it. :-)

Comments are disabled for this post (read why), but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.