Self-closing HTML tags and unclosed tags?

Discussion in 'HTML & Website Design' started by Mr.Dog, Dec 3, 2012.

  1. #1
    Hello,

    Sometimes I have problems by closing certain tags, namely the <img> tag.

    W3 Schools shows this example:
    <img src="smiley.gif" alt="Smiley face" height="42" width="42">

    But the V3 Validator and also other programs who me "unclosed tag", so I simply add </img>

    Another way is to write:
    <img src="image.gif"></img>

    What do you think about these, how is it best to code them? These and similar tags?
    As I know, there are self-closing tags, but in practice it doesn't always work. And I don't want to collect negative point in Google because of this.

    Tips, advice ideas?
     
    Mr.Dog, Dec 3, 2012 IP
  2. bowodesign

    bowodesign Member

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    i use something like this <img src="smiley.gif" alt="Smiley face" height="42" width="42" />
     
    bowodesign, Dec 3, 2012 IP
  3. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #3
    If you are validating as HTML, what you posted should be fine. It's valid HTML 4.01. If you're using xHTML then use what bowodesign posted.
     
    blueparukia, Dec 3, 2012 IP
  4. Mr.Dog

    Mr.Dog Active Member

    Messages:
    912
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Yes, that's exactly the way I code it, but some programs find that "unclosed"... wicked!
     
    Mr.Dog, Dec 3, 2012 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    <img ... /> is not unclosed. If the W3C validator passes it, it's valid (since they pretty much decide what's valid). If another validator says it's unclosed, you've found a defective validator.
     
    Rukbat, Dec 3, 2012 IP
  6. bowodesign

    bowodesign Member

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    what kind of program? better you change your program then, move to something like notepad++
     
    bowodesign, Dec 3, 2012 IP