Log in

View Full Version : Displaying an image on a webpage


Jess
October 10th, 2012, 08:33 PM
For a class, I have to create a webpage and right now I'm stuck on displaying a photo I took. I know the html code for it -- <img src="url"alt"text"/> but I'm having trouble figuring out the url. What would the pathfile be if I stored it in My Pictures?

Commander Thor
October 10th, 2012, 09:42 PM
It's usually best to keep your images within the directory of the site itself, or within an /images/ subdirectory. That way, you can simply reference the image using it's relative path at /images/<image>.png (Making it easy to move your site around)
So your directory tree would like something like this:
/site/index.htm
/site/images/image1.png
/site/images/image2.png
etc.

If you must put the images in a different directory from your .htm/html file, then the absolute path should work (C:\Users\<user>\Pictures\<image>.png) Making the syntax: <img src="C:\Users\<user>\Pictures\<picture1>.png" alt="Some Text">

Also, your HTML is a little off... Should be <img src="url" alt="alttext">.
(Space between alt & the closing quote of the url, equal sign between alt & the alt text, and you don't need a closing tag ( '/>' ) either.)

Jess
October 10th, 2012, 10:04 PM
Thanks. I took the pic using my webcam, so it's in jpeg instead of png. Can I use jpeg, or do I have to change to png? If yes, how would I convert the pic to png?

I created the webpage using Notepad++, so it's all in HTML, so I don't know how to create a directory for the images.....so yeah

HunterSteele
October 11th, 2012, 06:51 PM
Thanks. I took the pic using my webcam, so it's in jpeg instead of png. Can I use jpeg, or do I have to change to png? If yes, how would I convert the pic to png?
JPEG will be fine, you don't need to convert it.

Skyhawk
October 11th, 2012, 07:11 PM
Just use yourimagenamehere.jpeg or whatever the file type is.

e: <img src="C:\folder\folder\moar folder\image.jpeg" alt="alttext">
*Don't put "folder" where I did, hehe. :) Put whatever name is supposed to be there.

Jess
October 11th, 2012, 07:35 PM
I got it to show up now. Thanks everyone!