AD JB Toolbox 01 EN

HTML Tutorial / Links: Paths, Page Fragments, and Email

Create an HTML link with the a element and put its destination in href. The destination can be another page, a file, a location within a document, or an email address. Write link text that tells readers where they will go.

Create a basic link with a and href

Wrap the visible link text in a and put the target URL in href. This example leads to Coding Factory's Korean-language tutorial on HTML lists.

<a href="https://www.codingfactory.net/10225">HTML lists tutorial (Korean)</a>

“HTML lists tutorial (Korean)” is the visible text; the URL is the destination. An a without href is not a normal navigation link. Using href="#" as a placeholder can cause unexpected navigation to the top of the page.

Understand absolute and relative URLs

An absolute URL beginning with https:// includes the destination's domain. A relative URL can point to a file from the current document's location or from the site's root.

The following about.html and ../contact.html paths are practice examples, not pages that currently exist on Coding Factory. Assume you are writing the links in lessons/index.html in this folder structure:

site/
  contact.html
  lessons/
    index.html
    about.html
<a href="https://www.codingfactory.net/10225">Full URL</a>
<a href="about.html">About page in this folder</a>
<a href="../contact.html">Contact page one folder up</a>
<a href="/10225">HTML lists on this site</a>

about.html is resolved relative to the current document. A path beginning with / is resolved from the website's root. Local file:// files have a different root from a deployed website, so test relative paths again after deployment.

Link to a location within a document

Give the destination element a unique id, then use # followed by that value in the link.

<a href="#contact">Go to contact details</a>

<h2 id="contact">Contact</h2>
<p>Contact information goes here.</p>

To reach a location in another file, append the fragment to its URL: about.html#contact. Avoid repeating the same id within one page.

Email links and new tabs

A mailto: URL asks the user's email application to start a message. It may not work as expected if no mail app is configured.

<a href="mailto:hello@example.com">Send an email</a>

To open an external site in a new tab, use target="_blank" and the site's rel="noopener noreferrer" policy.

<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a"
   target="_blank" rel="noopener noreferrer">MDN's a element reference</a>

Choose a new tab when it suits the reader's task, and make the behavior clear in the link text or nearby explanation.

What the download attribute can do

The download attribute asks the browser to download a linked file. For example, it can be used for this image hosted on the same site.

<a href="/wp-content/uploads/html-image-sample-lake-tree-1600-v1.webp" download>Download the example image</a>

download works with same-origin URLs and with blob: and data: URLs. It cannot force a regular URL on another site to download. Even for a same-origin file, browser settings and the server response can affect what happens.

Check links before publishing

  • Use text such as “HTML lists tutorial (Korean)” rather than “click here.”
  • Test relative paths from the document's actual deployed location.
  • Check that a #id fragment exactly matches its destination.
  • Remember that email and download links depend on the browser and user environment.

See MDN's a element reference for more URL and attribute details.

More in This Category
HTML Tutorial / Divide a Page with Semantic Elements

HTML Tutorial / Divide a Page with Semantic Elements

Learn when to use header, nav, main, article, section, aside, and footer, then build a complete page whose regions and in-page links work together.

HTML Tutorial / Text Semantics: Emphasis, Quotations, Abbreviations, and Code

HTML Tutorial / Text Semantics: Emphasis, Quotations, Abbreviations, and Code

Learn when to use HTML em, strong, q, blockquote, abbr, code, and kbd. Examples show how each element conveys meaning rather than just changing the appearance of text.

HTML Tutorial / Table Basics: table, tr, th, and td

HTML Tutorial / Table Basics: table, tr, th, and td

Build a basic HTML data table with rows and header or data cells, then organize its headings and body without using tables for page layout.

HTML Tutorial / Lists: ul, ol, dl, and Nested Lists

HTML Tutorial / Lists: ul, ol, dl, and Nested Lists

Choose the right HTML list for ordered items, unordered items, and name–description pairs. Try a complete example, custom numbering, and correctly nested lists.

HTML Tutorial / Responsive Images: srcset, sizes, and picture

HTML Tutorial / Responsive Images: srcset, sizes, and picture

Offer image resolutions with srcset and sizes, and switch crops with picture. Downloadable files let you test the examples in a browser.

HTML Tutorial / Basic Structure of an HTML Document

HTML Tutorial / Basic Structure of an HTML Document

Learn the roles of doctype, html, head, and body, then save your first HTML file and open it in a browser. Includes a complete example, a diagram, and fixes for common filename, refresh, and encoding problems.

HTML Tutorial / Images: img, Alt Text, and Dimensions

HTML Tutorial / Images: img, Alt Text, and Dimensions

Add an image with HTML img, write useful alternative text, and set width and height correctly. A downloadable example helps you test file paths and sizing.

HTML Tutorial / Form Validation with required, Length, and Range Limits

HTML Tutorial / Form Validation with required, Length, and Range Limits

Apply built-in required, length, and numeric constraints, test error states, and understand why server-side validation remains necessary.

HTML Tutorial / Use textarea, select, option, and button

HTML Tutorial / Use textarea, select, option, and button

Create multi-line fields, selection lists, and form buttons while understanding initial values, submitted values, and reset behavior.

HTML Tutorial / When to Use div and span

HTML Tutorial / When to Use div and span

Understand the structural difference between div and span, style only the content you need, and choose semantic elements when they better describe the content.