This is not working:
<img src="../assets/images/image.jpg" alt="Alternative Text">
But this is working:
<img src="http://localhost/abc/def/geh/assets/images/image.jpg" alt="Alternative Text">
In my scenario, I just cannot work with absolute path. I have to use relative path.
Img src Not Working That means, when a web page loads, the browser has to retrieve the image from a web server and display it on the page. The broken link icon means that the browser could not find the image. If you've just added the image, then check that you included the correct image URL in the source attribute.
The img src stands for image source, which is used to specify the source of an image in the HTML <img> tag.
All <img> tags must have a defined src attribute. This defines the image to be displayed. Typically, the src is a URL, but a data representation of the image can also be used in some cases.
<img src="assets/images/image.jpg" alt="Alternative Text">
should be working.You shouldn't have put '../' at the begining of the image path.
For better understanding about relative paths vs. absolute paths, refer this link
"../assets/images/image.jpg" -This means
That relative link will only work if your page is in a subfolder in
"http://localhost/abc/def/geh/"
If the location of your page really is
"localhost/asdf/asdf/asdf/asdf/index.php"
(which seems ridiculous) to get to the assets folder relatively you would have to go all the way to the root.
'../../../../abc/deh/geh/assets/images/image.jpg;
Alternatively you could use a base tag in your head tag to make the URL in the actual src attribute more friendly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With