开发者

Validity of URL Syntax: which URL type to choose?

A valid URL no doubt:

<a href="http://w开发者_开发百科ww.website.org">...</a>

Question1: But is this shorthand als equally valid?

<a href="www.website.org">...</a>

Question2: is there any speed/other difference between the two?


The second URL you've provided is not valid; you need to supply the protocol which you wish to use:

<a href="ftp://...">ftp</a> <a href="mailto:example@domain.com>mail</a>

The second URL will assume it's looking for a local path.

Assuming your domain is www.website.org and you supply <a href="www.example.com">go to example.com</a> your browser will try and locate 'http://www.website.org/www.example.com'

Hope this helps.


To be conformant HTML, the URI needs to follow RFC2396. This means that all (non-relative) URIs start with a scheme, followed by a colon (and often two slashes). See section 3: http://www.ietf.org/rfc/rfc2396.txt

Note: I found that link by following the information on href here: http://www.w3.org/TR/html4/struct/links.html#h-12.2

Also, here's what the HTML5 spec says about valid URLs: http://www.w3.org/TR/html5/urls.html#valid-url

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜