xhtml syntax, is this legal?

Discussion in 'HTML & Website Design' started by MisterZee, Oct 2, 2005.

  1. #1
    Is this legal <a name="xyz" title="abc"></a> ?
    Or even <a name="xyz" title="abc" href=url></a> ?
     
    MisterZee, Oct 2, 2005 IP
  2. Amsterdam

    Amsterdam Well-Known Member

    Messages:
    361
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #2
    Amsterdam, Oct 3, 2005 IP
  3. MisterZee

    MisterZee Peon

    Messages:
    227
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I just tried it but couldn't understand the output.
     
    MisterZee, Oct 3, 2005 IP
  4. Mat

    Mat Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You need to submit a full page, complete with appropriate headers etc. I did this with the following between the body tags:

    <p><a name="xyz" title="abc" href="">test</a></p>

    and it passed xhtml strict validation. So yes, it's legal.

    Cheers,
    Mat
     
    Mat, Oct 5, 2005 IP
  5. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    in XHTML emplty tags should not be closed by the usual tag ender for that tag. if you put for example, <p></p> is invalid and should use <p /> instead. emplty tags must be closed with in. so unless u have <a>something</a> its invalid. use <a /> if u dont have the something.

    abt ur examples,

    <a name="xyz" title="abc" href=url></a>

    is invalid for two reasons. one, attribute values must be inside double quotes. so change href=url to href="url". two, as said earlier, empty tags should be closed with in. the valid version will be

    <a name="xyz" title="abc" href="url" />

    <a name="xyz" title="abc"></a> this should be changed to

    <a name="xyz" title="abc" />
     
    king_cobra, Oct 5, 2005 IP
  6. MisterZee

    MisterZee Peon

    Messages:
    227
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6

    Now I got it. Wow, complicated. I hope there are good reasons for all this protocol.
     
    MisterZee, Oct 5, 2005 IP
  7. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    its all for better parsing and thus better uniformity. if u know how regular expression parsers work, then u will understand how a well defined set of rules outshine a loosely defined one.
     
    king_cobra, Oct 7, 2005 IP
  8. MisterZee

    MisterZee Peon

    Messages:
    227
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #8
    That definitely makes sense. I just would have thought that <a some="something">soemthing</a> would be easier to parse than <a some="something" />, especially since some people will always mangle the code regardless :)
     
    MisterZee, Oct 7, 2005 IP
  9. mikmik

    mikmik Guest

    Messages:
    356
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Don't forget the break tag. I always forget this:
    <br />

    Also, you have to use a closing tag for scripts, don't you? A linked javascript goes
    <script type="text/javascript" src="file.js"></script>
    Code (markup):
    I think:eek:
     
    mikmik, Oct 8, 2005 IP
  10. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #10
    the break tag too follows the same XHTML rule of empty tages. html has <br></br>. but in XHTML it is <br />. also horizontal rule, its <hr /> and not just <hr> in XHTML.
     
    king_cobra, Oct 9, 2005 IP