Content · Web Development · HTML

HTML Protocol-Relative URLs: Why to Avoid Them

Protocol-relative URLs begin with // and inherit the current page's scheme. They were sometimes used to serve content under both HTTP and HTTPS.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Protocol-relative URLs begin with // and inherit the current page's scheme. They were sometimes used to serve content under both HTTP and HTTPS. The important question is always where the link leads and whether the person reading the page can predict it.

What You Need to Know


Today explicit https URLs are clearer and safer for sites that require secure transport. Avoid protocol-relative links in newly written examples.

Links are the pathways through a website. The words on a link should help someone choose where to go before clicking it.

Example: See It in Action


Add this example to the appropriate part of a practice HTML page. Read each line before you open the page in your browser.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<a href="https://example.test/news">Read the news</a>
<p>Write the https scheme instead of beginning an address with //.</p>
<p>A protocol-relative URL inherits the current page's scheme.</p>

Let’s Understand the Example


  • An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
  • A p groups a paragraph of related text. Start another paragraph for a new thought.
  • Href contains the destination of a link. A value starting with # points to an id on the same page.

The first example link points to https://example.test/news. Check whether that destination exists relative to the document. A link changes where readers go; it does not perform an action such as saving a form.

What Should You See?


You should see a link named “Read the news”. Selecting it leads to https://example.test/news when that destination exists. Try it with the mouse and the keyboard.

Imagine this link is read out of context. Would its text still explain the destination? Rename unclear links before trying to make them look nicer with CSS.

Try It Yourself


  1. Rewrite a protocol-relative example into an explicit HTTPS URL.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Writing //example.test and assuming it means a relative folder on your current site.
  • Avoid dead links, empty href values and clickable-looking text without a real destination.

Key Takeaways


  • Protocol-relative URLs begin with // and inherit the current page's scheme.
  • An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
  • Today explicit https URLs are clearer and safer for sites that require secure transport. Avoid protocol-relative links in newly written examples.
Share this resourceSend this page to someone who may find it useful.