Yo,

Can somebody tell me the code to put an image file in to an html document.
But not from a URL but from a file saved yo my computer!
Thanks ;)

Recommended Answers

All 3 Replies

You have to provide a path to the image. HTML documents use URLs for paths. If the image is in the same directory as your html file, then you use the filename.

The tag is "img":

<img src="myImage.jpg">

You have to upload your image first, you can't just host it off of your computer.

If your html page utilizes this image on multiple pages I would move the logic to a css file. It’s also good practice

You could do something like this in a css file if it were a background image or something. Just an example.

body{background: url(path/to/image/on/your/computer/image.gif)  repeat-y;}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.