Reputation: 31
Im trying to set up a hyperlink from my current page to another page via my files, however it doesn't work... My code:
<ahref="file:///C:/Users/ashsa_000/Desktop/Html/6weeksproject/Index/Languages.html"><input type="image" id="Languages" position:absolute style="height:px; width:px;" src="./CSImages/About.PNG">
<!-- Thats in context, the HREF is following-->
<ahref="file:///C:/Users/ashsa_000/Desktop/Html/6weeksproject/Index/Languages.html">
Once i click the hyperlink it comes up with an error that repeats the directory:
file:///C:/Users/ashsa_000/Desktop/Html/6%20weeks%20project/file///C:/Users/ashsa_000/Desktop/Html/6%20weeks%20project/Index/Languages.html
How can i fix this?
Upvotes: 0
Views: 357
Reputation: 851
<a href="file:///C:/Users/ashsa_000/Desktop/Html/6weeksproject/Index/Languages.html">
<input type="image" id="Languages" position:absolute style="height:px; width:px;" src="./CSImages/About.PNG">
</a>
As mentioned in comments, you should put a space between a
and href
. Additionally, you should close the a
tag.
Why are you using an input
element for showing an image? Maybe you are better off with an actual image tag:
<a href="file:///C:/Users/ashsa_000/Desktop/Html/6weeksproject/Index/Languages.html">
<img id="Languages" style="position:absolute; height:[insert missing value]px; width:[insert missing value]px;" src="./CSImages/About.PNG">
</a>
You may also have a look at this SO question for more reference on links to local files: How can I create a link to a local file on a locally-run web page?
Upvotes: 1
Reputation: 1773
Add the space in the a href
, put the image in an img
tag, and don't include height
and width
unless you are going to include a value. Also position:absolute
has to go in a style
tag. Finally, close your a
tag.
<a href="file:///C:/Users/ashsa_000/Desktop/Html/6weeksproject/Index/Languages.html">
<img src="./CSImages/About.PNG" style="position:absolute">
</a>
Upvotes: 0
Reputation: 1350
The <a>
must have a space between the a
and href
: <a href="">
When you use the href
attribute, the path will be based on which file you put the <a>
in, e.g. if you put the <a>
in the index.html
, and you want to reference to languages.html
, first make sure that the languages.html
is in the same folder as index.html
(easier) and then just reference to it with:
<a href="languages.html">
Also, why are you using an input
tag? Just use an img
tag. I'll fix your code:
<a href="languages.html">
<img id="Languages" style="position: absolute; height:_px; width:_px;" src="CSImages/About.PNG">
</a>
This only works if the folder CSImages is in the same directory as index.html
If not, just change the path accordingly.
Hope this helps!
Upvotes: 1
Reputation: 115
First of all, the tag in conjunction with the href
attribute work as follows <a href="path/to/file.html">
. Noticed the difference (space)?
Secondly, if the file is in the same folder, all you need to do is reference the file that you want to link starting from that path and upwards.
You were on the right track, your href would become: {}
Consider naming files with lowercase letters only. Its not necessary, but a well accepted practice!
Upvotes: 1