Image is not showing on html page - html

I am trying to add an image on html page but it doesn't appear
<img href="img/bg.jpeg" alt="welcom" />
everything seems to be fine what is wrong with code i test it many times
It test it on two browsers chrome 19 and firefox
I tried the same with another image extension but i doesn't work
<img href="img/2.png"/>
where is the problem

You're using the wrong attribute, instead of href you need to use src - the former is for links.
This would be the correct usage:
<img src="img/bg.jpeg" alt="welcom" />

The problem is just in: href the attribute
href attribute is for ancre link <a href="#">
<a href="directory">
The src attribute is for: img tag
<img src="directory"/>
and if you want to set a background with css you only have to add
background-image : url('directory');
Trust me its so easy to get confused by this stuff
So i suggest to change href attribute with src
<img src="img/bg.jpg" alt="Welcom" />
And it should work fine

You have to write
<img src="img/bg.jpeg" alt="welcom" />
istead of
<img href="img/bg.jpeg" alt="welcom" />

You need to use src not href to point to the image file name.
<html>
<img src="imagefilename.jpg">
</html>
This code will display an image with the filename imagefilename.jpg that is in the same directory as this html file

Related

Can't display image in HTML

Ok. I can't figure this out. Here's the HTML:
<html>
<body>
<img source="sample.jpg" alt="Wheres my image" style="width:100;height:38">
</body>
</html>
Pretty simple. The picture is just a simple block with some text in it. It's 2k in size. And for some reason I can't attach it here.
Both the image and the HTML are in the same sub directory in my Documents folder (Win10 x64 pro).
When I load the HTML, I just get the text from the "alt" setting for the image.
Browsers I'm testing on:
Chrome: 60.0.3112.113 (Official Build) (64-bit);
IE: Version 11.540.15063.0;
Edge: 40.15063.0.0, EdgeHTML version: 15.15063
Any ideas?
Try using this
<img src="sample.jpg" alt="Wheres my image" style="width:100;height:38">
You are using source insted of src that is causing error so change that. I hope this will work.
Change "source=" to "src=" other than that it should work.
Look here for more...
https://www.w3schools.com/html/html_images.asp
In your style add a unit to the width and height like 'px'. Then replace attribute source to src :)
<html>
<body>
<img src="sample.jpg" alt="Wheres my image" style="width:100px;height:38px">
</body>
</html>
The problem is that you have used the attribute source instead of src for your <img> tag.
Rewrite your image tag as:
<img src="sample.jpg" alt="Wheres my image" style="width:100;height:38">
If the image still won't load for you, there are three possible reasons why this may be happening:
You have forgotten to upload the image to the server.Check it's actually accessible by manually navigating to it.
You have referenced the file incorrectly, either by name or by path.
You need to clear your cache.Hold CTRL and click the refresh icon to clear your image cache.

Show an image when having the URL but not the path

The following link https://www.flickr.com/photos/39420315#N05/26406523594 is the URL of an image. I want to show it by using:
<img src="...">
How may I achieve that?
As simple as that:
<img src="https://www.flickr.com/photos/39420315#N05/26406523594">
The <img> tag expects a URL in the standard form, actually.

image not displaying in webpage, but link to image works

Im building a webpage and have the following code in the page:
<img alt="chat" href="images/chat.jpg">Chat now
The image "chat.jpg" is in the images folder, which is in the same folder as index.html, and if i browse to "localhost/site/images/chat.jpg" it displays but it doesnt show up in the index page at "localhost/site/index.html".
I have tried changing the href to "/site/images/chat.jpg" and the same thing happens.
There is no href attribute for img elements. You are looking for the src attribute.
Validators are useful tools.
This will work for your problem.
<img alt="chat" src="images/chat.jpg">Chat now

Hyperlinking a page to a local page (in files) HTML

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?
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!
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!
<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?
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>

Image not becoming a hyperlink [duplicate]

This question already has answers here:
how to attach url link to an image?
(2 answers)
Closed 8 years ago.
i have got this picture button on my site and i am trying to link it to another page using this code but it is not working at all :)
Here is the code. PLease help.
<img src="###" width="254" height="45"/>
The <img> part should be within the <a> tags...
<img src="###" width="254" height="45"/>
Basic HTML rules are that the link is what falls between the opening and closing <a> tags, whether text or image.
You want it as this:
<img src="###" alt="alt text">
The width and height tags are deprecated as you should use CSS for them, but the alt tag is required for HTML5 validation.
Having img tag within a tag says that associate a link to my image and show the image once clicked. You can also add "target=_blank" to open your image in new tab.
### would be the link
<a href="###">
<img src="###" alt="my image" width="254" height="45" target="_blank" />
</a>
Learn more at MDN
If you want image to be linkable, you need to place img tag inside the anchor tag
<img src="img source" />