How can I link to a file on my own computer?


How can I link to a file on my own computer?


If you are working locally and you wish to link to another file, you usually want this other file to share the same parent directory as the file from which you are linking. This allows you to use a relative path as the value to an anchor’s href attribute. You will learn more about how to create relative paths in exercise 8 of this lesson.


I think in modern browsers the files have to be in the Web directory of your Web Server, you can no longer link directly to files that are elsewhere on the local machine.


Consider the possible locations for resources on a web connected computer.


Just because we are working locally doesn’t mean we can’t use web URLs in our requests. For instance, say we have a development environment on our local machine that we wish to share across other devices. It follows the more resources we have on the web the less we need to share between the devices. Ultimately, the only thing shared between devices is the APP that drives everything.

Okay, that was a mouthful. The point it makes is that it makes perfect sense to establish a web, or cloud presence for shared content so devices don’t need to carry that extra baggage. Having it on demand is the way to go.

Create an account with a decent CDN and upload all media to that store. Now the URLs in your app point to that resource, not your local volume.

Now focus on containerizing your app. That’s where Angular.js, Express.js and React.js come in (and where I leave off).


Hi, sorry for asking this question after so much time but I couldn’t help myself to do so.
So in the lesson of the anchor element, there’s a line stated as " The paths provided to the href attribute are often URLs". Why does it say “often”? Does it mean that “href” can also contain other contents rather than only URLs?


Page fragments don’t require URLs, which are resolved by a name server. All that we need to link to them are the global identitifiers (id attribute).

<a href="#top">Jump to top of page</a>

The above link will return the user to the top of the current page (scroll to target element).

<div id="top">


Other uses of href are less obvious. For instance, when a block quote is from another site. If we include this hook reference we attribute the source.

<blockquote href="">


I have a question. What does href mean. I know it is the name of the attribute, but what does it mean?


HTTP Reference, but some of us still call it a, hook reference as it relates to an anchor.


Hi mtf,
What’s the difference between blockquote cite vs blockquote href?

1 Like

Not a lot, really. They both are URLs to the source of the quote. cite would be the preferred attribute in HTML5 and Living Standard.


Just started HTML, please help. How can i link to my file in my PC while using html page in codecademy lesson?

1 Like

What’s the rush? You just started and there is nowhere in this course that you are asked to link to a file on your computer. Any files we are meant to link to are provided.

:slight_smile: no rush at all, just out of curiosity

1 Like

So you know, it is not possible to link to files on your computer. If you have an image that belongs to you, then it could be uploaded to a content host and linked from there. Another option is to upload it to a post, then copy the url and use that in your code. It will be hosted by CC’s CDN. Then delete the post.

Bottom line, your computer is off limits to the web. Keep it that way.

We could copy the URL of this image and use it in the Brown Bear exercise.

Off Topic

Ever seen, Romance Romance? It’s a two act play from the eighties. It ran on Broadway for nearly a year then the rights were passed to Howard Pechet, my boss at the time. We produced the play at Stage West, with Shaun Cassidy in the lead male role. He played ‘Theodore’ in the First Act, and we tricked him on the last night, the 66th performance.

Shaun is one of the most consistent actors I have ever witnessed in live stage. He is so consistent, the Stage Manager said, ‘what the heck just happened?’ during the scene where Theodore is at his armoire (SR), and Josephine at her vanity (SL), in the middle of some correspondence in which she says, ‘Good night, Teddy’. It is at this moment that Theodore opens the door to his armoire and sees this very doll staring right at him. I had conspired with the set dresser to plant it, and then secret it away during scene change. We pulled it off.

Shaun would not talk about it, later. Hope we didn’t put him off his otherwise brilliant performance of this play. The set dresser and I never told a soul about this. Talk about an inside joke.

FTR, I was running the followspot on Theodore so caught every second of it. He hesitated, then jumped right back into the groove without skipping a beat. But, we caught it, those on the stage management and production team.

Fortunately his mom had already left so she didn’t see it, or there would have been h e l l to pay. She was visiting shortly before.

Bottom line, all the precision in the world is still no guarantee against the unforeseen. Someone out for a laugh could derail our program. And do it anonymously.

Howard is the World Record holder for most produced plays.


Thank you very much!

Hi Roy, it is a bit late reaction but what’s CC’s CDN, where can i look it up
thanx much in advance,

The only way I know to store something on the CDN is to upload it in a post. This is not something to play with, though, and should not be exploited for one’s own ends. Bottom line, use the images that CC provides and leave their CDN alone.

1 Like

Hello , I know its a bit late but what it means by : Same Parent Directory . Does it mean same server or browser or something else?