- Blog
- Web Development
HTML Link Code: Page, Phone, Email And File Links
In HTML, the a tag and the href attribute are used to create a link. The text the visitor sees is written between the two tags. The same structure can point to pages, files, phone numbers and email addresses.
Linking To A Page
<a href="/iletisim/">Get In Touch</a>
This address opens the contact page of the same site. For an external site you can use the full address:
<a href="https://example.com/">View The Example Site</a>
The link text should give information about the place that will open. Instead of writing “Click Here” everywhere, I prefer a descriptive phrase such as “Review The Proposal Terms.”
Phone And Email Links
<a href="tel:+905327291801">Call By Phone</a>
<a href="mailto:hello@hasancircioglu.com">
Send An Email
</a>
These are HSNCRC’s contact details, used as an example; change them in your own project. A tel: link can open the calling app the device supports. mailto:, on the other hand, directs to the user’s email app. It does not send email by itself from the site’s server.
Going To A Section Of The Page
<a href="#sik-sorulan-sorular">See The Questions</a>
<section id="sik-sorulan-sorular">
<h2>Frequently Asked Questions</h2>
<p>You can find information about the project in this section.</p>
</section>
The section name in href and the id must be the same. Do not give the same id value to more than one section.
If a fixed top menu covers the heading, this adjustment can help:
section[id] {
scroll-margin-top: 6rem;
}
Opening In A New Tab
<a
href="https://example.com/"
target="_blank"
rel="noopener"
>
View The Example Site — New Tab
</a>
You do not have to open every link in a new tab. For navigation within the same site, I prefer to use the current tab. If an external link is going to open in a new tab, stating this clearly is a good usability choice.
File Link
<a href="/dosyalar/ornek-katalog.pdf" download>
Download The Sample Catalog
</a>
Check that the file is really at that address. The download behavior can depend on the browser, the address of the resource and the server’s response; do not assume it will force a download for every external file.
Link Or Button?
If the user goes to another address, use a link; if an action is performed within the page, use a button. For example, opening the contact page is a job for a link, and submitting the form is a job for a button.
<button type="submit">Send The Request</button>
This distinction is independent of visual styling. A link can look like a button with CSS.
Frequently Asked Questions
Can I Write # Instead Of An href?
# does not take the place of a real destination. Prefer not to show a link that is not ready as if it were active.
Does A Link Have To Be Underlined?
It should be clear that it is a link. If you remove the underline, provide color, position or another distinct visual cue.
Is A WhatsApp Link Added With The Same Tag?
Yes. You can write the correct wa.me address in the href field.
Related Guides
You can take a look at the guides on creating a WhatsApp link and adding images with HTML.