The right way of setting <a href=""> when it's a local file

Viewed 231709

I'm trying to link to a local file. I've set href as follows:

<a href="file://C:/path/to/file/file.html">Link Anchor</a>
  • In Firefox, when I right click and "open link in new tab", nothing happens.

  • When I right click and "copy link location", then manually open a new tab and paste the copied link, it works fine. So it seems my file:// syntax is fine. I've also tried it with 3 slashes like file:/// but it's the same result.

What am I doing wrong?

7 Answers

Try swapping your colon : for a bar |. that should do it

<a href="file://C|/path/to/file/file.html">Link Anchor</a>

The right way of setting a href=“” when it's a local file. It will not make any issue when code or file is online.

<a href="./your_file_name.html">FAQ</a>

Hope it will help you.

Related