The <img> tag

Discussion in 'HTML & Website Design' started by edrectory, May 30, 2009.

  1. #1
    Can i use the alt="" attribute in a <img> tag before the src="", if possible this would make it so much easier to add alt="" tags to all the images shown on my site and then only have to add little bits to it.
     
    edrectory, May 30, 2009 IP
  2. Sapphiro

    Sapphiro Well-Known Member

    Messages:
    1,242
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    175
    #2
    Yes you can, but it basically makes no difference having it before or after your src attribute.

    But in practice, most html coders prefer to code the more important attributes first, which in this case is the src attribute. :)

    btw, do it the right way with xhtml, html is a big no no now. ;)
    <img src="" alt="" />
    Code (markup):
     
    Sapphiro, May 30, 2009 IP
  3. edrectory

    edrectory Peon

    Messages:
    368
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Why is html a big no no :)?
     
    edrectory, May 31, 2009 IP
  4. Sapphiro

    Sapphiro Well-Known Member

    Messages:
    1,242
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    175
    #4
    well you can say html is a very loose language, you could do <b><i>adf</b></i> and it still worked, now people prefer following a stricter format, so it's way better to start learning xhtml instead of html. It's basically the same, except stricter syntax. ;)

    HTML: (loose format)
    <IMG SRC="" WIDTH=50 HEIGHT=50>
    Code (markup):
    still works.

    but the best way is to follow xhtml, and it would look like this:
    <img src="" width="50" height="50" alt="" />
    Code (markup):
    Just an example. :D
     
    Sapphiro, May 31, 2009 IP
  5. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #5
    @ Sapphiro: That would be wrong. The example you gave is just as invalid in html as it is in xhtml. Unless the xhtml is served as application/xhtml+xml, the browser will treat either the same as the other. As far as the browser is concerned, both are html, and both are parsed with error tolerance.

    HTML4.01 is the current standard for html. Use it unless you have compelling reason to extend the DTD, in which case, you use the .xhtml file name extension, modify the server's content-type header, or use a server side scripting language to specify the content-type header . You may use the xhtml syntax and DTD as content-type=text/html, then it's still html.

    cheers,

    gary
     
    kk5st, May 31, 2009 IP
  6. LCCEnterprise

    LCCEnterprise Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Gary is right.
    I've been in the programming field for many of years now.
    I never use the .html extension either. I always use .php because I always have functions on the pages, that are php.
    =)
    If you need anyhelp, Don't hesitate to ask me.
     
    LCCEnterprise, May 31, 2009 IP