Correct anchor syntax for xhtml

Status
Not open for further replies.

lato

New Member
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.
 

daviddoran

New Member
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)
 

niall

New Member
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.
 

daviddoran

New Member
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)
 

lato

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

louie

New Member
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.
 

daviddoran

New Member
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..
 
Status
Not open for further replies.
Top