+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 11

Thread: Correct anchor syntax for xhtml

  1. #1
    lato is offline Frontpage User lato will become famous soon enough
    Join Date
    Feb 2007
    Posts
    23

    Default Correct anchor syntax for xhtml

    What is the compliant code, with regard to xhtml, for;

    1)Internal page linking .
    2.)Another page on the same server.
    3) Open in a new window.

    Upfront, thanks for any definitive answer.

  2. #2
    daviddoran's Avatar
    daviddoran is offline Wannabe Geek daviddoran will become famous soon enough
    Join Date
    Aug 2006
    Location
    Meath, Ireland
    Posts
    342

    Default

    I'm not totally sure what you want answered with the first to, but there goes:
    1) To link internally in the page:
    Code:
    <a href="#anchor" title="Anchor Title">Link to anchor</a>
    
    2) To link to another page:
    Code:
    <a href="another_page.htm" title="Another Page">Another Page</a>
    
    3) To open new window
    Code:
    <a href="another_page.html" onclick="window.open(this.href); return false;" title="Another page new">Open in new window!</a>
    
    The third one is strange but is correct because XHTML has deprecated the target attribute and since the window target is deemed an interaction-level element it should either be specified by javascript or CSS (css3 I believe)

  3. #3
    niall's Avatar
    niall is offline Hosting Caretaker niall will become famous soon enough
    Join Date
    Jan 2007
    Location
    Carlow
    Posts
    85

    Default

    Quote Originally Posted by daviddoran View Post
    I'm not totally sure what you want answered with the first to, but there goes:
    1) To link internally in the page:
    Code:
    <a href="#anchor" title="Anchor Title">Link to anchor</a>
    
    This might be just a matter of personal taste, but are you not better off using single quotes? My main reasons using single rather than double quotes are:

    1. It's faster to type (no shift key required)
    2. It's doesn't require escaping in php (no backslash and shift key)

    From a quick search, it seems that it should be double quotes (source), but xhtml strict validates with single quotes on the w3c validator.

  4. #4
    daviddoran's Avatar
    daviddoran is offline Wannabe Geek daviddoran will become famous soon enough
    Join Date
    Aug 2006
    Location
    Meath, Ireland
    Posts
    342

    Default

    I have always used double-quotes and I think we'd find that 95% of links to aswell.
    1) I suppose but it is practically the same since you insert a double-quote with two different hands (I.E. It's still pratically one keystroke)
    2) Well, if we want to get pedantic using single-quotes to escape PHP strings is faster for PHP to interpret and because double quotes are wider they are easier to see in the string.

    That's my view anyway.

    As for quoting attributes both single and double are valid, with similar quoting rules (Singles ok in double, double ok in single)

  5. #5
    lato is offline Frontpage User lato will become famous soon enough
    Join Date
    Feb 2007
    Posts
    23

    Default

    Thank you Sir,
    Open in a new window though?
    Can we do this xhtml? rather than js?
    And thanks in either case.

  6. #6
    louie's Avatar
    louie is offline Senior Member louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough
    Join Date
    Jan 2006
    Location
    Dublin, Ireland
    Posts
    2,328

    Default

    yes, you can use
    Code:
    <a href="page.php" target="_blank" title="you page">Link</a>
    
    and if needed you can do the rezise on the new page with javascript.
    :. Web Design & Development Web Design Ireland
    :. Search Engines Optimization Search Engines Optimization
    :. Car Parts & Accessories Car Parts
    :. Cars Ireland Cars Ireland
    :. I Have 2 Find It Directory SEF Directory

  7. #7
    lato is offline Frontpage User lato will become famous soon enough
    Join Date
    Feb 2007
    Posts
    23

    Default

    Great!
    Thanks.

  8. #8
    daviddoran's Avatar
    daviddoran is offline Wannabe Geek daviddoran will become famous soon enough
    Join Date
    Aug 2006
    Location
    Meath, Ireland
    Posts
    342

    Default

    Quote Originally Posted by louie View Post
    yes, you can use
    Code:
    <a href="page.php" target="_blank" title="you page">Link</a>
    
    and if needed you can do the rezise on the new page with javascript.
    I'm not sure why he asked about XHTML in the first place if he wanted the old HTML answer..

  9. #9
    louie's Avatar
    louie is offline Senior Member louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough
    Join Date
    Jan 2006
    Location
    Dublin, Ireland
    Posts
    2,328

    Default

    beats me.
    :. Web Design & Development Web Design Ireland
    :. Search Engines Optimization Search Engines Optimization
    :. Car Parts & Accessories Car Parts
    :. Cars Ireland Cars Ireland
    :. I Have 2 Find It Directory SEF Directory

  10. #10
    SlitheryImp is offline Member SlitheryImp will become famous soon enough
    Join Date
    Jan 2006
    Location
    Dublin, Ireland
    Posts
    84

    Default xhtml compliant

    As David said, target="_blank" is not xhtml (although it is xhtml transitional), here is another idea, and it is xhtml strict compliant. It also uses javascript though...

    Weblog Tools Collection » Blog Archive » target=”_blank” XHTML 1.0 Strict Conversion
    Last edited by SlitheryImp; 20-04-2007 at 07:13 PM.

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Optimization by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64