Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

Regarding inserting images in html files

I have been trying to insert images in my html files, but they are ending up being broken images. I really can't figure out where exactly l am going wrong. Is there anybody to make some suggestions ?
 
Check the path given in the HTML image, and then check the site files to see it this is referenced correctly.
path-to/image.png will mean the image image.png is in a folder called path-to, and that folder is in the same folder as the html file.
If it helps, can you post the html code for the image?
 
Where is your html file located?
You can use relative paths, so ./image-name.jpeg if the html file is also on your desktop, or you can also use absolute file paths, which start with / meaning the root directory, so it'll be something like /Users/[user name]/Desktop/image-name.jpeg assuming you're on windows.

Read more about file paths here: HTML File Paths - W3Schools
 
Hey There!
The location of your HTML file determines how you reference other files. You can use relative paths, such as ./image-name.jpeg, if the HTML file is in the same directory (e.g., on your desktop). Alternatively, you can use absolute paths, which start from the root directory. For example, on Windows, it might look like /Users/[your username]/Desktop/image-name.jpeg.
 
Hello @Debaashish84 ,

Given this file (directory) structure:

MyProject
├─ css
├── styles.css
├─ images
├── myimage.jpg
├── myimage1.jpg
├── myimage2.jpg
├─ index.html

The path for one of the images in index.html would be:

<img src="images/myimage.jpg" alt="" width="" height="">
 
I have been trying to insert images in my html files, but they are ending up being broken images. I really can't figure out where exactly l am going wrong. Is there anybody to make some suggestions ?
if you refer to the image direclty as
HTML:
<img src="imagname.jpg">
then you need to make sure that the image is in the same folder as the file in which you are including the image otherwise you gotta give refernce to the image with respect to the file for example if the image is in a folder called "images" and the folder and the file are in the same folder then do
HTML:
<img src="./images/imagname.jpg">
where the . refers to the current folder
while if you want to refer to the previous folder you use ..
 
Back
Top Bottom