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

Hi Quick Question, when adding a src image file, how will the coding distinguish between http:// and https://?

I just noticed when adding a src img using http:// and https:// can actually affect the image, so I was wondering in certain cases how will our coding recognize this kind of situation or how do we code accordingly?

1 Answer

You only want to put an absolute url using https:// when the image is on a secure server. While writing demo or test code you are most likely to be doing this on a non-secure server. Images to http or https are fine.

On a secure server, like your public facing website, it is important NOT to mix http and https assets. All images on a secure page should be imported from secure servers too.

If you are using assets on the same site as your html pages then you don't need an absolute url. You can use just the path from either root or relative the the current page (avoiding the need to specify a port).