SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Corner seat
    Posts
    1,069
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can alt tag have empty string like alt=''?

    To make my site as much w3c compliant as possible, I've been making number of changes. One of changes is alt tag, but I am not so sure if all alt tags should have value. i.e., some images(<img ...) are just there to create a nice line or curve. I'm wondering if I should really be writing something like alt='line' and alt='curve'. Anyone experience doing something similar? Should I put alt='line' and alt='curve'? Or should I just use empty string like alt='' because if the image is not there, what alt tag says can just be annoyance?

  2. #2
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Think of the text as rather than alternative display, instead as "alternative content". If an image is just decoration, it has no content, so the best alt is just that: alt=""

    You're spot on.

    Douglas
    Hello World

  3. #3
    SitePoint Addict
    Join Date
    Sep 2003
    Location
    Europe
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And note the double quotes!

  4. #4
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Corner seat
    Posts
    1,069
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And note the double quotes!
    We can use double single-quote alt='' can we? Instead of double double-quote alt=""? Does it make any difference?

  5. #5
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The norm. is to use double quotes, but technically AFAIK you can still use single quotes.

    And yeah - basically if it's an important navigational item, make sure you give it a clear alt tag with meaning. If it's something like the rounded corner on a table which has no meaning, just leave it blank.

  6. #6
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,267
    Mentioned
    116 Post(s)
    Tagged
    1 Thread(s)
    If you want the site to validate as XHTML, you need to use the double quotes. If you don't care about that, then using the single quotes is OK.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  7. #7
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Corner seat
    Posts
    1,069
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want the site to validate as XHTML, you need to use the double quotes. If you don't care about that, then using the single quotes is OK.
    That brings another question. So ... it's not just alt tag but every tag needs to use double-quote " in order to be validated as XHTML(which is exactly what I want to do ultimately). Is that right? For example, <td class='default'> should be <td class="default"> instead and so forth.

  8. #8
    SitePoint Evangelist NokX's Avatar
    Join Date
    Feb 2003
    Location
    Knoxville, TN
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup...it's a nice habit to get into, using double quotes, when you're defining attributes in a tag. especially when you start incorporating some things like this...

    Code:
    <img src="images/mypicture.jpg" onclick="location.href="anotherpage.html"" />

  9. #9
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,267
    Mentioned
    116 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by stoli_sambuca
    That brings another question. So ... it's not just alt tag but every tag needs to use double-quote " in order to be validated as XHTML(which is exactly what I want to do ultimately). Is that right? For example, <td class='default'> should be <td class="default"> instead and so forth.
    That would be correct. All attributes must be delineated with the double quote.

    For a good reference on the difference between XHTML and HTML, you can try the section at w3schools.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  10. #10
    Vermicious Knid moncur's Avatar
    Join Date
    May 2003
    Location
    Salt Lake City, UT
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Note that using single quotes occasionally causes browser errors, too. I'm not sure which browser, but I had all kinds of weird malformed URLs showing up in my error logs before I standardized on double quotes.


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
  •