Article image Links in HTML

Links in HTML

Page 7 | Listen in audio

Links in HTML

Links are one of the most important elements in HTML as they allow users to navigate between different web pages. In HTML, links are created using the <a> tag, which stands for "anchor".

To create a link, you need to specify the URL of the page you want to link to. The URL is the string of characters that uniquely identifies a web page. For example, the Google home page URL is https://www.google.com.

To link to Google, you can use the following HTML code:

<a href="https://www.google.com">Google</a>

In this example, the text "Google" is the link text that will be displayed on the page. The href attribute specifies the URL the link points to.

In addition to the href attribute, you can also add other attributes to the <a> element. For example, the target attribute specifies where the linked page will open. If you set the attribute value to "_blank", the page will open in a new browser window. For example:

<a href="https://www.google.com" target="_blank">Google</a>

You can also add a title to the link using the title attribute. The title is displayed as a tooltip when the user hovers over the link. For example:

<a href="https://www.google.com" title="Go to Google">Google</a>

In addition, you can link to specific sections of a page using anchors. Anchors are bookmarks within a page that allow you to link directly to a specific section. To create an anchor, you need to add the id attribute to an element on the page. For example:

<h2 id="my-section">My section</h2>

To create a link to this section, you can use the following code:

<a href="#my-section">Go to my section</a>

In this example, the href attribute value starts with a hash sign (#), followed by the id attribute value of the element you want to link.

In summary, links are a fundamental part of HTML and allow users to easily navigate between different web pages. With the <a> tag, you can create links to other websites, specific sections of a page, and even open pages in a new browser window.

Now answer the exercise about the content:

_What is the role of the "target" attribute in the <a> tag in HTML?

You are right! Congratulations, now go to the next page

You missed! Try again.

Article image Tables in HTML

Next page of the Free Ebook:

8Tables in HTML

2 minutes

Earn your Certificate for this Course for Free! by downloading the Cursa app and reading the ebook there. Available on Google Play or App Store!

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text