2 minutes of reading

How to Add a Link in HTML? Beginner's Guide

How to Add a Link in HTML? Beginner's Guide - Image 1

Linking in HTML - differences between internal and external links

Need to redirect a user to another page, an external website, or a PDF file? Or perhaps you're just starting to learn coding and wondering how to add a link in HTML?

Creating links in code is one of the absolute foundations of building websites.

In this step-by-step guide, we explain what a tag is in HTML, how the href attribute works, and how to correctly create a hyperlink in HTML, avoiding mistakes that can harm your SEO and usability.

How to Add a Link in HTML? HTML Link Syntax in Practice

The basis of every link in HTML is the <a> tag (from the English "anchor"). It is responsible for creating hyperlinks in a document.

(The rest of the article can be found below the form)

Fill out the form and schedule a call with an expert

We'll get to know your business and prepare a personalized quote for the optimal marketing mix. Completely free.

The controller of your personal data is Verseo, a limited liability company with its registered office in Poznań, at ul. Węglowa 1/3.

About Verseo

The Company's registered office is located in Poznań. The Company is entered in the Register of Entrepreneurs maintained by the District Court for Poznań – Nowe Miasto and Wilda in Poznań, 8th Commercial Division of the National Court Register, under KRS number: 0000910174, Tax Identification Number (NIP): 7773257986. You can contact us by mail at the address provided above or by email at: ochronadanych@verseo.pl

You have the right to:

  1. access to your data,
  2. rectification of your data,
  3. request deletion of data,
  4. processing restrictions,
  5. object to the processing of personal data,
  6. transfer of personal data,
  7. withdrawal of consent.

If you believe that we are processing your data contrary to legal requirements, you have the right to lodge a complaint with the supervisory authority – the President of the Personal Data Protection Office.

We process your data for the purpose of:

  1. handling your inquiry, pursuant to Article 6(1)(b) of the General Data Protection Regulation (GDPR);
  2. marketing purposes consisting in the promotion of our goods and services and ourselves in connection with the consent you have granted, pursuant to Article 6(1)(a) of the GDPR;
  3. securing or pursuing possible claims in connection with our legitimate interest, pursuant to Article 6(1)(f) of the GDPR.

Providing your data is voluntary . However, without it, you will not be able to send us a message, and we will not be able to respond to you.

We may transfer your data to trusted recipients:

  1. providers of tools for: website traffic analysis, sending marketing information.
  2. entities responsible for hosting (storing) the website and personal data.

We will process your data for the period of:

  1. necessary to achieve the specific purpose for which they were collected, and after its expiry for the period necessary to secure or pursue any claims
  2. in the case of data processing based on consent until its withdrawal. Withdrawal of consent does not affect the lawfulness of processing prior to withdrawal.

We do not process personal data in a way that would involve making solely automated decisions about you. More information regarding the processing of personal data can be found in our Privacy Policy.

The syntax of an HTML link is simple and is based on the following structure:

<a href="adres-strony">Tekst linku</a>

The most important element here is the href attribute, which specifies the address to which the link should lead. This can be a full URL (e.g., https://adresstrony.pl/) or a relative path within the website (e.g., /blog).

The text between the opening and closing tags is a text link (anchor) – visible and clickable to the user.

Creating links in code – internal links and external links

Creating links in code can involve various types of links. The most common are internal links and external links.

Internal links lead to other pages within the same domain and aid in navigation and SEO. For example:

<a href="/kontakt">Skontaktuj się z nami</a>

External links, on the other hand, direct the user to another website:

<a href="https://przykładowyadres.pl">Sprawdź źródło</a>

External links often use additional attributes, such as target=”_blank” to open the page in a new tab. However, for security reasons, it's worth also adding rel=”noopener noreferrer”.

<a href="https://przykładowyadres.pl" target="_blank" rel="noopener noreferrer">Sprawdź źródło</a>

Hyperlink in HTML as text link and graphic link (link in image)

A hyperlink in HTML doesn't have to be text only. A text link (anchor) is the most common, but you can also create a graphic link , meaning a link within an image. Simply place the <img> tag inside an <a> tag :

<a href="https://adresstrony.pl"><img src="baner.jpg" alt="Nasza oferta"></a>

In this case, clicking the image will take the user to the specified address. Using the alt attribute , which describes the image's content, is crucial – this is important for both accessibility and SEO.

Regardless of the link's form, it's important to ensure a clear and natural anchor text. Instead of a generic "click here," it's better to use descriptive phrases that inform users and Google's crawlers where the link leads.

Dofollow and nofollow links – how do they affect SEO?

Dofollow and nofollow links also play a role in SEO . By default, these links don't have the nofollow attribute, so they can transmit ranking signals (commonly referred to in the industry as dofollow).

A dofollow link can transmit ranking signals to the target page. If you want to limit this effect, you can add the rel=”nofollow” attribute . In practice, it looks like this:

<a href="https://przykładowyadres.pl" rel="nofollow">Link sponsorowany</a>

The nofollow attribute tells search engines not to treat the link as a recommendation. Google currently treats it as a guideline, not a strict directive.

For advertising and affiliate links the attribute rel=”sponsored” is also used , and for user-generated content (e.g. comments) – rel=”ugc”.

The most common mistakes when creating links in HTML

Although the syntax for an HTML link is simple, beginners often make mistakes. Common ones include missing the "https://" protocol in external links, typos in the href attribute, or linking to a nonexistent page (a 404 error).

Another problem is the overuse of general anchors and the mass opening of all links in new tabs without justification.

If you already know how to add a link in HTML, remember that good linking isn't just a technical matter. It's also a key element of UX and SEO strategy . A properly constructed hyperlink in HTML facilitates navigation, supports indexing, and helps users find the information they need faster.

FAQs about HTML links

The anchor tag (from the English word "anchor") is used to insert hyperlinks in HTML . For the link to function properly, this tag must include an href attribute, which declares the target URL.

If you don't want the user to leave your site after clicking on the link (which is recommended when linking to external websites), you should add the target=”_blank” attribute to the tag.

Anchor text is the visible, clickable content of a link on a page (usually highlighted in blue or underlined). Both users and Google crawlers should clearly understand what's on the other side of the click. Instead of writing unnatural phrases like "click here" or "see," it's much better (and SEO-safe) to use a description like "see full price list" or "read HTML tutorial."

Yes, almost any element on a page can be a link, including an image. To create a clickable graphic, simply place an image tag () between the opening and closing link tags (...).

  • Absolute URLs: These contain the full path to the page, including the protocol (e.g. [https://verseo.pl/kontakt/](https://verseo.pl/kontakt/)). They are required when linking to a completely different (external) domain.
  • Relative URLs: These contain only a portion of the path and refer to the current location on the server (e.g., /contact/). They are typically used for internal linking (between pages on the same site), making code management easier and improving page performance.

The rel="nofollow" attribute is a special directive for search engine robots (e.g., Google). It tells the algorithms: "My site links to this address, but I don't want to transfer my SEO trust and authority (link juice) to it." This attribute is used, among other things, to mark sponsored posts, affiliate articles, and in comment sections to prevent spam.

Summary

The above article covers the following topics:

  • The guide explains how to correctly create links in HTML using the href tag and attribute.
  • Internal links lead to subpages on the same domain, while external links lead to other websites and require additional attributes for security and user convenience.
  • A hyperlink in HTML can be text or an image, and it is crucial to use descriptive content and alt attributes to improve SEO and accessibility.
  • Attributes like nofollow, sponsored, and ugc allow you to control how ranking signals are passed on to target pages, which is crucial for your SEO strategy and the proper marking of external links.
  • Avoiding technical errors, such as typos in addresses or the lack of HTTPS protocol, combined with a well-thought-out UX and SEO strategy, is essential to creating properly functioning and effective linking.