Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a link without the protocol valid XHTML? i.e. <a href="//www.example.com/">

Is it valid XHTML / good practice to have links of the following form? //www.example.com/foo/bar.html

If the current page is HTTP, then the link points to: http://www.example.com/foo/bar.html If the current page is secured under HTTPS, then the link points to: https://www.example.com/foo/bar.html

In other words, is

<a href="//www.example.com/">

valid in XHTML 1.1 Strict? And, is it supported by many/all browsers?

like image 677
BMiner Avatar asked Apr 20 '11 19:04

BMiner


People also ask

Can links in HTML have non HTML protocols?

They support all the protocols supported by browsers- ftp, mailto, file etc. Also, you can preceed URL name with '#', to link to a html id internally in the page. You can give just the name or directory path, without a protocol, which will be taken as a relative URL.

Do you need https in href?

So yes you need to put http, https, or www, just to let browser know that you redirecting user somewhere outside of this site(server), or it will try to find path you specified on current server. It is because each link is just a path to some document and protocol explicitly says that it is other server.

What prefix is used in href value while creating email links?

To do that, just use the id of the section with a # as the prefix for the href value. So, when you click on the Go link, you will scroll to the news section of the page. Demonstration of the in-page link. You can try it using the Anchors app.

Is the HTTP protocol used in the href value?

Is the http protocol used in the href value? Use relative link when we want to link to pages on our own website. The href for a relative hyperlink does not begin with the http:// and does not include domain name.


1 Answers

Is it valid XHTML

Completely. XHTML doesn't care about the syntax of URIs. The href attribute is defined as containing CDATA.

valid in XHTML 1.1 Strict?

There is no such language.

XHTML 1.0 has Strict / Transitional / Frameset versions.

XHTML 1.1 is just XHTML 1.1. (And isn't blessed by rfc2854 for serving as text/html (which you need for IE < 9 support)).

And, is it supported by many/all browsers?

Yes. Support is fine.

like image 78
Quentin Avatar answered Oct 01 '22 12:10

Quentin