Learning HTML – Learning the basics of HTML
Adding links
To add a link, you use markup again. Let's say you want a link to your company's web site URL, http://www.mywebsite.com. You need to do two things: mark which part of your text will be a link, and indicate the URL. The tag <a> shows what part is to be linked. In this example, "our website" will have a link:
<p>If you'd like to know more, visit <a>our website</a>.</p>
To complete setting up the link, you must add the URL to the starting <a> tag, using a hypertext reference (an href). The format for this is
href="http://www.mywebsite.com"
Some hints: The URL is quoted. There are no spaces between the href, equal sign or the location. Here's how it to enter it in your web page:
<p>If you'd like to know more, visit
<a href="http://www.mywebsite.com">our website</a>. </p>
When you open the page in a browser, you'll see:
If you'd like to know more visit our website.
Experiment with adding links to different popular websites, until you feel comfortable with using the links. To link to another page in the same directory as your current web page, you use the same format. You don't have to enter the full URL, just the page name.
<p>See the <a href="page2.html">Next Page</a></p>
When you open the page in a browser, you'll see:
See the Next Page
Getting links to work right can be a challenge. Probably the most common mistake is a typo in the URL. On way to avoid this is to go to the site to which you're linking and copy the URL directly from the address bar in the browser. Another common mistake is to forget to enclose the URL in quotes. |