Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Jason Widjaja
Jason Widjaja
7,904 Points

Make local images global

How do i make images from my file in computer global?so I view the website I made on my mobile device and no pictures are showing up and I am guessing this is because the images I linked are from my own data not the web how do I make my images visible to everyone

Jason Widjaja
Jason Widjaja
7,904 Points

i tried the putting in image but when tried opening my website in another device the styles still does not pop up.when I tried opening the file that I sent to my other device on the original computer where I coded my HTML it also does not have the style. i am confused on what the problem is

2 Answers

What you could do is to create a folder containing all files needed in your project and inside that one, you create a folder named images and you put all the images you are going to use so the when viewing it on mobile, the image path is relative to the project directory, not your computer!

All your website files and images need to be uploaded to a server (a Website Hosting service) to be visible to the world.

If you're able to view your website on other devices, that means you must've uploaded the HTML to a server. You'll need to upload your images (probably your whole images folder) to that same server, in the same area. If you keep your HTML and image files together, you can do as Victor says and your image paths remain relative to the directory.

Relative image path: images/IMAGENAME.jpg Where "images/" is your folder, and the "IMAGENAME.jpg" is the specific image.

Jason Widjaja
Jason Widjaja
7,904 Points

i tried the putting in image but when tried opening my website in another device the styles still does not pop up.when I tried opening the file that I sent to my other device on the original computer where I coded my HTML it also does not have the style. i am confused on what the problem is.Then how do these websites have pictures that everyone can access? do they have to upload all the images their using to the web and link it there?

I see what you're doing. You're sending the .HTML file to yourself and opening it on another device. Is that correct?

If so, you have to send your entire project folder (including images and stylesheets) to the other device in order for the images and styles to load. Otherwise, all the <link>s and <imgs>s are broken (because they don't exist on those devices).

The way public websites work is that all of those resources are uploaded to a server (website hosting service) that serves up all website files and folders (like images and code).