Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Semantics - What does that mean?

    Hi all,

    I've read several posts here recently that mention having code that is "semantically correct"... then I just read a post that said (I think) that the markup can be valid but not semantically correct...

    Okay - I'm confused.

    Could someone define "semantically correct" for me - being a bit anal myself I like the idea already.

    Thanks
    Dodge

  • #2
    cfc
    cfc is offline
    Regular Coder
    Join Date
    Dec 2004
    Location
    Keswick, Ontario
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I beleive that "semantically correct" refers to elements being used for what they're supposed to be used for.

    For example, tables are valid XHTML but their use for layout is not semantically correct as most page layouts aren't exclusively tabular data.

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Semantically correct usage of elements means that you use them for what they are meant to be used for. It means that you use tables for tabular data but not for layout, is means that you use lists for listing things, strong and em for giving text an emphasis, and the like.

    Edit: You know, when I first read the title of this thread I thought it was a pun...
    Last edited by liorean; 02-25-2005 at 08:45 AM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Quote Originally Posted by Dodge
    markup can be valid but not semantically correct...

    Okay - I'm confused.
    Here's an example: a menu contained with a blue box.

    Valid, well-formed... not semantically correct:
    Code:
    <div id="blue">
     <div id="menu">
      <div class="link"><a href="#">link</a></div>
      <div class="link"><a href="#">link</a></div>
      <div class="link"><a href="#">link</a></div>
     </div>
    </div>
    Actually, it's not really semantically incorrect, either... it's just semantically empty.

    Valid, well-formed, semantically correct:
    Code:
    <ul id="menu">
     <li><a href="#">link</a></li>
     <li><a href="#">link</a></li>
     <li><a href="#">link</a></li>
    </ul>
    The CSS will define the ul as being a blue container box. Now we've got some meaning here (an unordered list of links).

    A read through the HTML/CSS archives will have some great discussions on various semantics, as it can sometimes boil down to personal opinion (i.e., what describes this better, this or this?)

  • #5
    New Coder
    Join Date
    Jan 2005
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How interesting! Thanks for the expanations.!

    I will do some reading on this.

    Thanks
    Dodge

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Meaning

    Maybe it was already said in a sort of roundabout way, but semantics is all about adding meaning.
    The purpose of markup is adding meaning to plain text; semantically correct markup is thus adding correct meaning.
    If a piece of text is supposed to be a header, correct markup would use a header element.
    If a piece of text is supposed to be a paragraph, you mark it up as one.
    An unordered list of items? Guess what: ul's and li's.
    Andsoon, andsoforth.

    Why would you do this? Semantically correct markup provides instant style hooks, default styling for when CSS is not applicable (text browsers, screen readers, etc.), and an indication to SE spiders to assess the relevance of your pages.
    Regards,
    Ronald.
    ronaldvanderwijden.com

  • #7
    New Coder
    Join Date
    Jan 2005
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Where are these HTML/CSS archives you speak of? =)

  • #8
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    oh, I meant just looking through some of the previous posts here in the HTML/CSS forum. Some good ones:

    http://codingforums.com/showthread.php?t=51046
    http://codingforums.com/showthread.php?t=39420
    http://codingforums.com/showthread.php?t=39586
    http://codingforums.com/showthread.php?t=34638

    Really, any thread in the html/css forum will probably involve semantics in some way... if you're into it I'd suggest reading through every question when they pop up just to see if you grasp something new.

  • #9
    New Coder
    Join Date
    Jan 2005
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rmedek
    Really, any thread in the html/css forum will probably involve semantics in some way... if you're into it I'd suggest reading through every question when they pop up just to see if you grasp something new.
    Agreed - and that's what I have been doing. I'm trying to play the part of a sponge and soak up as much as I can.

    I even read the questions/replies from the forums I'm not directly involved in (JavaScript, ASP, etc...) hoping to retain and use it at a later time.

    I very much appreciate the replies to this topic and have been trying to approach my code with semantics in mind.

    Thanks
    Dodge


  •  

    Posting Permissions

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