HTML links are used to create hyperlinks between web pages, or to link to other resources such as images, videos, or documents. To create a link in HTML, you use the <a>
(anchor) tag.
Here is an example of how to create a hyperlink in HTML:
<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
</head>
<body>
<h1>Welcome to my web page!</h1>
<p>Check out my <a href="https://www.example.com">favorite website</a>.</p>
</body>
</html>
In this example, the <a>
tag is used to create a hyperlink to the website https://www.example.com
. The href
attribute of the <a>
tag specifies the destination of the hyperlink.
When a user clicks on the hyperlink, they will be taken to the specified web page or resource. The text within the <a>
tag is typically underlined and displayed in a different color than the surrounding text to indicate that it is a hyperlink.
You can also create links to other pages within your own website by using relative URLs instead of absolute URLs. For example:
<p>Check out my <a href="about.html">about page</a>.</p>
In this example, the href
attribute specifies a relative URL (about.html
) instead of an absolute URL. This would create a link to an about.html
page located in the same directory as the current HTML document.
Links can also be styled using CSS to change their appearance, such as their color, text decoration, and more.