Semantics vs bold and italics
In his article When Semantic Markup Goes Bad, Matthew Thomas writes about why always replacing
<strong> is bad, which is absolutely correct. Instead, he suggests using
<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
<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
<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.