Links Hyperlinks

In HTML, hyperlinks are created using the <a> (anchor) tag. Hyperlinks are fundamental to the web, allowing users to navigate between different pages, sections of the same page, or even to trigger downloads or open email clients.

Syntax

<a href="url">link</a>

Example 1 : Link to Another Web Page
<a href="https://www.whereisstuff.com">whereisstuff.com</a>

Try it yourself

Example 2 : Link to a Section of the Same Page (Anchor Link)
<!DOCTYPE html>
<a href="#section1">Go to Section 1</a>
<div style="height:100vh"></div>
<div>
<h2 id="section1">Section 1</h2>
<p>This is the content of Section 1.</p>
</div>

Try it yourself

Example 3 : Link to an Email Address and Download
<!DOCTYPE html>
<a href="mailto:info@example.com">Email Us</a>
<a href="/files/sample.pdf" download>Download PDF</a>

Try it yourself


Target Attribute

Attribute
Description
_blank
Opens in a new tab or window.
_self
Opens in the same tab or window (default).
_parent
Opens in the parent frame.
_top
Opens in the full body of the window.
Example 1 : Target
<!DOCTYPE html>
<a href="https://www.whereisstuff.com" target="_blank" title="site name">Open Example in a New Tab</a>
<a href="https://www.whereisstuff.com" target="_self" title="site name">Opens in the same tab or window (default).</a>
<a href="https://www.whereisstuff.com" target="_parent" title="site name">Opens in the parent frame.</a>
<a href="https://www.whereisstuff.com" target="_top" title="site name">Opens in the full body of the window.</a>

Try it yourself

Note

title: Provides additional information about the link, usually displayed as a tooltip when hovering over the link.


Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.