when to use <em> and <strong>?

Discussion in 'HTML' started by John Salerno, Jan 26, 2006.

  1. John Salerno

    John Salerno Guest

    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?
     
    John Salerno, Jan 26, 2006
    #1
    1. Advertising

  2. 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
     
    Jonathan N. Little, Jan 26, 2006
    #2
    1. Advertising

  3. John Salerno

    John Salerno Guest

    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!
     
    John Salerno, Jan 26, 2006
    #3
  4. John Salerno <> 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.
     
    Joel Shepherd, Jan 26, 2006
    #4
  5. John Salerno

    Mark Parnell Guest

    Deciding to do something for the good of humanity, John Salerno
    <> 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/
     
    Mark Parnell, Jan 26, 2006
    #5
  6. John Salerno

    Mark Parnell Guest

    Deciding to do something for the good of humanity, "Jonathan N. Little"
    <> 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/
     
    Mark Parnell, Jan 26, 2006
    #6
  7. 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
     
    David Dorward, Jan 26, 2006
    #7
  8. John Salerno

    Mark Parnell Guest

    Deciding to do something for the good of humanity, David Dorward
    <> 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/
     
    Mark Parnell, Jan 26, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Digital Puer
    Replies:
    27
    Views:
    5,152
    James Rogers
    Sep 13, 2003
  2. Abhishek Saksena
    Replies:
    7
    Views:
    375
    Maxim Yegorushkin
    Aug 10, 2005
  3. namekuseijin

    Re: "Strong typing vs. strong testing"

    namekuseijin, Sep 27, 2010, in forum: C Programming
    Replies:
    214
    Views:
    3,472
    Nick Keighley
    Oct 17, 2010
  4. namekuseijin

    Re: "Strong typing vs. strong testing"

    namekuseijin, Sep 27, 2010, in forum: Python
    Replies:
    229
    Views:
    3,576
    Gregory Ewing
    Oct 29, 2010
  5. Nicola Garone

    How to strong name an assembly which use interop.shell32?

    Nicola Garone, Apr 15, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    369
    Nicola Garone
    Apr 19, 2004
Loading...

Share This Page