SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <span> and elements

    hi there.
    I'm learning from your book "build your own web site the right way", on page 110 its written, that its more "appropriate" to use element :

    Code:
    <p> do it <strong>now</strong></p>
    and not :

    Code:
    <p>do it <span class="shouty">now</span>,/p>
    Can someone please help me understand when its better to use span over and element ?

    Thank.
    -----
    Nob Hill Software - Tools for database people.

  2. #2
    SitePoint Guru kish's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is a semantic meaning to tags like <strong> and <em>, since you are explicitly declaring that the text within those tags is being highlighted or emphasised.

    Using a span has no semantic meaning - it's purely to control to look/layout.

    You can still control <strong> and <em> using CSS, if you really want to, or you can just let the browsers interpret and render them in the default way (usually as bold and italics). A screenreader may also find it useful to have these marked up semantically so it knows where to place the emphasis in reading.

    To be honest, there's little point in making a more complex stylesheet with uneccesary classes, when html does the job fine.

    Cheers
    Fast Fwd Multimedia
    Web, IT & Cloud Computing Consultancy
    Currently looking for web freelancers. Get in touch!

  3. #3
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Itamar View Post
    Can someone please help me understand when its better to use span over and element ?
    Just adding onto Kish's comment's, the general perspective is that you should only use span when another element cannot better describe the content. Essentially span is a "meaningless" wrapper for when you want to give something style that doesn't stand out from the rest of the text. It's sort of a "when all else fails" tag.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •