Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > when to use <em> and <strong>?

Reply
Thread Tools

when to use <em> and <strong>?

 
 
John Salerno
Guest
Posts: n/a
 
      01-26-2006
I understand that you shouldn't use these tags to italicize or bold
text, but what exactly is meant when you want to "emphasize" text? It
seems like any use of <em> is somehow tied to the fact that it will use
italics, and I wonder if people would use it as much if it didn't. So
I'm trying to grasp how you really use it for markup only.

Also, as an example, what if I had a sentence like this:

"The word void in a function indicates that there is no return type."

If I'd like 'void' to stand out from the rest of the sentence (and
ideally have it italicized), should I use <em>? I know I should have
italics as a consideration when I choose <em>, but like I said it's hard
not to.

The only other option I can think of would be:

<span class="keyword">void</span>

but is that a better way to do it?
 
Reply With Quote
 
 
 
 
Jonathan N. Little
Guest
Posts: n/a
 
      01-26-2006
John Salerno wrote:
> I understand that you shouldn't use these tags to italicize or bold
> text, but what exactly is meant when you want to "emphasize" text? It
> seems like any use of <em> is somehow tied to the fact that it will use
> italics, and I wonder if people would use it as much if it didn't. So
> I'm trying to grasp how you really use it for markup only.
>
> Also, as an example, what if I had a sentence like this:
>
> "The word void in a function indicates that there is no return type."
>
> If I'd like 'void' to stand out from the rest of the sentence (and
> ideally have it italicized), should I use <em>? I know I should have
> italics as a consideration when I choose <em>, but like I said it's hard
> not to.


Basically I think <em> is by default tied to italic by tradition in
print, but of course you can always change this to something more to
your liking in your stylesheet


>
> The only other option I can think of would be:
>
> <span class="keyword">void</span>
>
> but is that a better way to do it?


Depends if you are just highlighting a specific word or phrase then 'em'
and 'strong' will do but if there is some underlining theme to the
emphasis then I could see where classes can be very useful, e.g.

..keyword { color: #080; }
..constant { color: #f00; }
..command { color: #008; }

<span class="keyword">void</span>
<span class="constant">NULL</span>
<span class="command">sub</span>

which gives you the flexibility if latter you rethink the color coding a
bit garish then all you have to do is change your stylesheet...

..keyword, .constant, .command { color: #f00; font-weight: bold; }





--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
 
 
 
John Salerno
Guest
Posts: n/a
 
      01-26-2006
John Salerno wrote:

> If I'd like 'void' to stand out from the rest of the sentence (and
> ideally have it italicized), should I use <em>? I know I should have
> italics as a consideration


*shouldn't* have it as a consideration...oops!
 
Reply With Quote
 
Joel Shepherd
Guest
Posts: n/a
 
      01-26-2006
John Salerno <(E-Mail Removed)> wrote:

> Also, as an example, what if I had a sentence like this:
>
> "The word void in a function indicates that there is no return type."
>
> If I'd like 'void' to stand out from the rest of the sentence (and
> ideally have it italicized), should I use <em>?


Probably not: there's more going on there than simple emphasis. It's not
equivalent to, say, "Your <em>what</em> hurts?!"

> I know I should have italics as a consideration when I choose <em>


Actually, you shouldn't. You should think of <em> as saying "the content
should be presented with emphasis". Italics don't enter the picture.
It's true that many browsers use italics to denote emphasis but there's
no requirement that they or you do so.

> The only other option I can think of would be:
>
> <span class="keyword">void</span>
>
> but is that a better way to do it?


I think so. The fact that in some contexts "void" is a keyword is
semantically important. HTML has no way to represent that bit of
semantics (though maybe <code> comes close: I forget if it's deprecated
or not). Emphasis is far enough removed from status as a programming
language keyword that it's probably not a good idea to, uh, overload it
with that meaning.

--
Joel.
 
Reply With Quote
 
Mark Parnell
Guest
Posts: n/a
 
      01-26-2006
Deciding to do something for the good of humanity, John Salerno
<(E-Mail Removed)> declared in alt.html:

> It
> seems like any use of <em> is somehow tied to the fact that it will use
> italics,


In graphical UAs perhaps.

> and I wonder if people would use it as much if it didn't. So
> I'm trying to grasp how you really use it for markup only.


Try listening to it with a screen reader. That may give you a different
perspective.

--
Mark Parnell
================================================== ===
Att. Google Groups users - this is your last warning:
http://www.safalra.com/special/googlegroupsreply/
 
Reply With Quote
 
Mark Parnell
Guest
Posts: n/a
 
      01-26-2006
Deciding to do something for the good of humanity, "Jonathan N. Little"
<(E-Mail Removed)> declared in alt.html:

> Depends if you are just highlighting a specific word or phrase then 'em'
> and 'strong' will do but if there is some underlining theme to the
> emphasis then I could see where classes can be very useful, e.g.
>
> .keyword { color: #080; }
> .constant { color: #f00; }
> .command { color: #008; }


No argument there, but...

> <span class="keyword">void</span>
> <span class="constant">NULL</span>
> <span class="command">sub</span>


Better to use <em class="keyword"> etc. That way in non-graphical UAs,
and those that don't support CSS, it will still be emphasised.

--
Mark Parnell
================================================== ===
Att. Google Groups users - this is your last warning:
http://www.safalra.com/special/googlegroupsreply/
 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      01-26-2006
Mark Parnell wrote:

>> <span class="keyword">void</span>
>> <span class="constant">NULL</span>
>> <span class="command">sub</span>

>
> Better to use <em class="keyword"> etc.


Looks more like a job for <code class="keyword"> to me.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
Mark Parnell
Guest
Posts: n/a
 
      01-26-2006
Deciding to do something for the good of humanity, David Dorward
<(E-Mail Removed)> declared in alt.html:

> Looks more like a job for <code class="keyword"> to me.


Heh - point taken.

I wasn't looking at the specific example given by the OP - just the fact
that if it is meant to be emphasised, <em> is the correct element,
regardless of what styling you may want to apply.

--
Mark Parnell
================================================== ===
Att. Google Groups users - this is your last warning:
http://www.safalra.com/special/googlegroupsreply/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If I use the WAP add-on, can I not use GridView paging and sorting? Chris S ASP .Net 0 12-13-2006 10:03 PM
When to use #define and When to use const? Peng Yu C Programming 7 12-08-2004 05:08 AM
How do I know when to use the Viewstate and when to use the posted data? :-) Simon ASP .Net 1 11-09-2004 02:32 AM
Can I use XPath or something to a remote Mac or Linux box and just query an xml file, not using web services and use encyrption? jake ASP .Net 0 07-06-2004 02:16 PM
[Q] when to use pointer and when to use reference? Yuming Ma C++ 4 11-25-2003 08:59 PM



Advertisments