The simplest way to create a web link

A web link is created using HTML code called an anchor tag. The basic structure is <a href="URL">link text</a>, where you replace "URL" with the web address you want to link to, and "link text" with the words that appear clickable to the reader. For example, <a href="https://www.example.com">Visit Example</a> creates a clickable link that says "Visit Example" and goes to example.com when clicked.

The href attribute tells the browser where to send the visitor. You must include the full web address, starting with http:// or https://. The https:// version is more secure and is what modern websites use. Everything between the opening <a> tag and the closing </a> tag becomes the clickable text the reader sees.

Key Takeaways

  • Every web link uses the anchor tag structure: <a href="URL">text</a>, where the URL must start with http:// or https://.
  • The text between the opening and closing tags is what appears clickable on the page; the href attribute is invisible to readers.
  • Links to pages on your own website can use relative paths like href="about.html" instead of the full web address.
  • You can open a link in a new tab by adding target="_blank" inside the opening tag, like <a href="URL" target="_blank">text</a>.
  • Email links use a different format: <a href="mailto:email@example.com">text</a>.

Links to other websites versus your own pages

When you link to a website you do not own, you must use the complete web address. This is called an absolute URL. Write the full address exactly as it appears in your browser's address bar: <a href="https://www.wikipedia.org">Wikipedia</a>.

When you link to a page on your own website, you can use a relative URL, which is shorter and more flexible. If you have a file called about.html in the same folder as your current page, you can write <a href="about.html">About Us</a>. If the file is in a subfolder called pages, write <a href="pages/about.html">About Us</a>. Relative links break if you move your files to a different folder structure, so test them after any reorganization.

Opening links in a new tab or window

By default, a link opens in the same tab or window where the reader is viewing your page. To open the link in a new tab instead, add target="_blank" to the opening tag: <a href="https://www.example.com" target="_blank">Visit Example</a>.

This is useful when you link to external websites and want to keep your own page open in the background. However, do not overuse it — most readers expect links to behave normally, and opening new tabs without warning can feel intrusive. Use target="_blank" only when there is a clear reason, such as linking to a tool or resource the reader will want to reference while staying on your page.

Creating email links

An email link lets readers send you a message by clicking a link. Use the format <a href="mailto:your-email@example.com">Email Us</a>. When clicked, this opens the reader's default email program with your address already filled in as the recipient.

You can also add a subject line that appears automatically in the email. The syntax is <a href="mailto:your-email@example.com?subject=Contact Request">Email Us</a>. Replace "Contact Request" with the subject you want. If your subject has multiple words, replace spaces with %20, like subject=Website%20Feedback.

Styling and formatting links

Links are usually blue and underlined by default in web browsers. You can change their appearance using CSS, the language that controls how web pages look. For example, you might make links red, remove the underline, or change the color when someone hovers over them with their mouse.

Even if you style a link to look different, keep it visually distinct from regular text so readers know it is clickable. A common approach is to use a different color or add a background highlight. Avoid making links look exactly like regular text, because visitors may not realize they can click them.

Linking to a specific section of a page

You can link directly to a heading or section within a page using an anchor. First, add an id attribute to the heading you want to link to: <h2 id="contact">Contact Us</h2>. Then create a link to that section using <a href="https://www.example.com#contact">Go to Contact</a>. The # symbol tells the browser to jump to the section with that id.

This works for linking to sections on the same page too. If you want a link that jumps to the contact section on your current page, use <a href="#contact">Jump to Contact</a>. This is helpful for long pages where you want to let readers skip to the information they need.

Common mistakes to avoid

The most frequent error is forgetting the http:// or https:// at the start of external URLs. Without it, the browser treats the address as a relative link and looks for a file on your own website instead of going to the external site. Always check that external links start with the protocol.

Another mistake is using spaces or special characters in id attributes. Stick to letters, numbers, hyphens, and underscores. If your heading is "Frequently Asked Questions", use id="faq" or id="frequently-asked-questions", not id="Frequently Asked Questions". Spaces and punctuation can cause the link to fail silently.

Do not forget the closing </a> tag. Every opening tag needs a closing tag, or the link will not work correctly and may break the formatting of the rest of your page.

Frequently Asked Questions

What is the difference between href and target?

The href attribute tells the browser where to go when the link is clicked. The target attribute controls how the page opens — target="_blank" opens it in a new tab, while the default behavior opens it in the current tab. You need href to make the link work; target is optional and changes only the behavior.

Can I link to a PDF or a downloadable file?

Yes. Use the same anchor tag format but point the href to the file instead of a web page: <a href="document.pdf">Download PDF</a>. When clicked, most browsers will either open the file or prompt the user to download it, depending on browser settings and file type.

Do I need to include www in the URL?

Not always. Most modern websites work with or without www, so https://example.com and https://www.example.com both work. Check the address bar of the site you are linking to and use the version that appears there. Consistency matters more than the presence of www.

What happens if the URL I link to no longer exists?

The link becomes broken. When someone clicks it, they see an error page (usually a 404 message). Regularly check external links on your website and update or remove ones that point to pages that have been deleted or moved.

Can I link to a specific word in the middle of a sentence?

Yes. The anchor tag can wrap any text, including a single word. <a href="https://www.example.com">click here</a> makes only those two words clickable. However, "click here" is not descriptive — readers benefit more from links that describe where they are going, like <a href="https://www.example.com">our pricing page</a>.