Forum Moderators: not2easy
Remember that <strong> and <em> are markup so if you're a nice coder then you'll have to make sure they are really warranted. (I cheat all the time btw)
If you need to bold text for purely visual purposes then best go with the <span> and class.
Knowlse:
hehe, happens to me all the time! ;);)
Nick
There are occasions when you might want to use bold or italic text for reasons other than emphasis, when <em> and <strong> would be inappropriate (especially for audio browsers) -- this was discussed a few weeks ago. An example might be foreign words, which are usually set in italics:
She displayed a certain joie-de-vivre.
It would be wrong to use <em> here, because you are not trying to emphasise the words, merely to set them off visually. Personally, I prefer to use <i> with a lang attribute, because it is actually more efficient than using CSS. Compare:
.foreign { font-style: italic; }
<span class="foreign" lang="fr">joie-de-vivre</span>
with:
<i lang="fr">joie-de-vivre</i>
As CSS-2 becomes better supported, though, a future solution should be:
span[lang] { font-style: italic; }
<span lang="fr">joie-de-vivre</i>
...still a little more verbose, but easier to change if you have a lot of foreign words and phrases.
There are some other structural tags which usually render in italics which you should use where appropriate. These are:
<cite> for titles of books and other publications, e.g. Charles Dickens' <cite>David Copperfield</cite>
<var> to represent text in a sample of code which the user should replace with actual code, e.g. Copy the file using <code>copy(</code><var>temp_variable</var><code>, </code><var>destination_file</var><code>)</code>
<address> marks up contact information
<dfn> marks up a technical term which is explained at that point (usually the first occurrance), e.g. A <dfn>labio-dental fricative</dfn> is the sound produced by placing the lower lip against the top row of teeth and forcing air out of the mouth.
Bold text is much less frequently used.
Note that large amounts of either bold or italic text is actually difficult to read on screen: use them very sparingly.
I often use several classes called things like "menu", "highlight" or "explanation" and place them all over the site long before I start thinking of how they will look