need help with valid xhtml in text area

Discussion in 'HTML & Website Design' started by phantom, Dec 5, 2007.

  1. #1
    I have this code:

    <textarea rows="7" cols="19"><a href='http://domain.com' title='Fun><img src='http://domain.com/imgs/88x31.gif' border='1' alt='Fun'/></a>
    </textarea>
    Code (markup):

    that doesn't validate.



    Here is the error I get from http://validator.w3.org


    
    …domain.com' title='Fun'><img src='http://domain.com/imgs 
    
    The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
    
    One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).
    
    Code (markup):


    Any Ideas on how to fix it so that it validates?

    Thanks in advance!
     
    phantom, Dec 5, 2007 IP
  2. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #2
    You can't put links or images in a textarea, it is for text only.
     
    blueparukia, Dec 5, 2007 IP
  3. phantom

    phantom Well-Known Member

    Messages:
    1,509
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    140
    #3
    phantom, Dec 5, 2007 IP
  4. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #4
    A background image could be put, but an image I think not. That's why the validator said it's improper nesting, you can't put an <img> tag inside a <textarea> tag.
     
    Dondon2d, Dec 5, 2007 IP
  5. phantom

    phantom Well-Known Member

    Messages:
    1,509
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    140
    #5
    ok its not an image though........I am trying to make display the code for an image...does that make sense? This is so that people can copy the code for a linked button.
     
    phantom, Dec 5, 2007 IP
  6. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Change all opening angle brackets ("<") to "&lt;" and all closing angle brackets (">") to "&gt;". The code will validate, and the text inside the textarea will appear the same.
     
    Dondon2d, Dec 5, 2007 IP
  7. phantom

    phantom Well-Known Member

    Messages:
    1,509
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    140
    #7
    Awesome........thanks!
     
    phantom, Dec 5, 2007 IP
  8. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #8
    No problem, glad to be of help ;)
     
    Dondon2d, Dec 5, 2007 IP