Technouz

Fix Error: HTML Hyperlink Being Appended To Current URL

By Zahid Mahmood / 10 August 2015

html 5When working with HyperText Markup Language (HTML) a common error for newbies is the use of hyperlinks. Hyperlink allow you to link from one page to another using the **

**

**

[Notice that in both cases, the URL starts with the HyperText Transfer Protocol identifier (HTTP). This is essential in order to tell your browser that it must use the HTTP protocol to open an external webpage.

In addition the URL must be consistently wrapped with either a single or double apostrophe. This is crucial for those who may draft content in word processing applications such as Microsoft Office Word where the apostrophes are automatically converted to speech marks for punctuation. Your browser does distinguish between them and may not recognise the link between two punctuation symbols. This could very easily result to a hyperlink being appended to your URL and is difficult to troubleshoot with the eye.

Anchor URL

If your href attribute contains a number sign (#) the browser will look for the anchor link within the same page. Therefore ensure that your intended external URL does not contain a number sign, or that you have not mistakenly included one in your code.

By default, anchor links with no preceding URL value will result in the hyperlink being appended to the current URL.

Preceding Slash

If your href attribute starts with a slash, this tells your browser to look within a local directory.

For example:

](http://technouz.com)-

[Is telling the browser that the link is within a local directory. The first example is explicitly directing the browser to a subfolder of the current working directory, so naturally it will append to the current URL, whereas the second example will go up a directory before navigating to the linked file.

](../subfolder/file.html)

Thanks for reading!

My name is Zahid Mahmood, and I'm one of the founders of Anterior. I started this technology blog when I was in high school and grew it to over 100,000 readers before becoming occupied with other projects. I've recently started writing again and will be posting more frequently.