On the web you can link to absolutely anything, but let's say that you want to create a link to the front page of CNN.com. Obviously CNN is not under your control. In this case you must provide the full and complete URL - a simple
www.something.com is not sufficient.
- Read this article on <a href="http://www.cnn.com">CNN</a>
Note that the easiest way to guarantee that you have the URL correct is to navigate to the site, page, or resource using your browser, highlight all the text in the URL bar (ALT+D), copy it (CTRL / CMD + C) and paste it into the appropriate
href value in your page.
Also note that some longer URLs, particularly (but not exclusively) those that contain
GET information, may cause the W3C to claim it is invalid. This is not your fault. You will simply need to replace some characters in the URL with their HTML entity equivalents: for example, writing
& to replace any
& characters in the URL string.
Note that modern browsers do allow two code shortcuts in order to save file size. First, the opening http: may be dropped, so long as the // remains to indicate that the information is a URL; second, if you are writing HTML5, quotes are optional so long as the URL does not contain any "weird" characters. Under those conditions, our link could become:
- <a href=//www.cnn.com>Go to CNN</a>