NorS
NorS

Reputation: 158

How to make a picture link with HTML?

I have made a picture link with this code snip:

<a href='feed.php'><img src="C:\xampp\htdocs\Project\Icons\Feed.png"/></a>

But no picture appears on my page, why?

(I'm currently only using my page locally!)

Upvotes: 0

Views: 2132

Answers (2)

PeeHaa
PeeHaa

Reputation: 72672

It's because you (are trying to) use a local file reference.

Either use the relative path

or

<a href='feed.php'><img src="file:///C:/xampp/htdocs/Project/Icons/Feed.png"/></a>

Please be aware that if you plan to use this 'online' it will fail because of the LOCAL reference.

If you load the page through your webserver you should use:

<a href='feed.php'><img src="/Icons/Feed.png"/></a>

Or

<a href='feed.php'><img src="http://yoursite.local/Icons/Feed.png"/></a>

Or whatever the path to the image is.

I would prefer the relative path (the first) though which enables you to move your page to another domain without your links / images breaking.

Upvotes: 1

Unsigned
Unsigned

Reputation: 9916

You can't link local files from a remote web page. This is to prevent webpages from accessing files on the end-user's computer.

Change this: C:\xampp\htdocs\Project\Icons\Feed.png

To this: http://yourwebsitehere.com/Project/Icons/Feed.png

EDIT: Since you say its only used locally, then you need to use this instead: file:///C:/xampp/htdocs/Project/Icons/Feed.png

Also, make sure the image is actually located where you think it is!

Try typing file:///C:/xampp/htdocs/Project/Icons/Feed.png into your browser's address bar and see what happens.

Upvotes: 1

Related Questions