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

Image srcset how can I get this to work correctly?

Hello,

I am trying to get my images to change from portrait for mobile and tablet devices to landscape images for desktop devices, but my srcset code is not working? Can anyone see what I am doing wrong here?

<script src="js/picturefill.min.js" async></script>

```  <img 
                   srcset="../Images/islal11.JPG 2000w, 
                          ../Images/islap11.JPG 700w, 
                          ../Images/islap11.JPG 300w"
                    src=" ../Images/islap11.JPG"
                   alt="girl wearing headphones image"
                   class="image"
                 />

2 Answers

Hi Tracy!

Check your image path if it's correct. I can see that you have extra space on your "src" attribute.

src="../Images/islap11.JPG"

Come back to me if this works.

Cheers!

  • Owa

Thank you for picking up the mistake, it still didn't work so I tried:

<picture>

                <source media="(max-width: 720px)" type="image/jpg"
                srcset="../Images/islap11.JPG">

                <source media="(max-width: 1024px)" type="image/jpg"
                srcset="../Images/islal11.JPG">

                <img src="../Images/islap11.JPG" alt="girl wearing headphones image"    class="image">

           </picture>

and no luck there either, am I coding this wrong, using the wrong tool??

Can you share a snapshot of your current workspace?

Hi it's a personal project on my computer will just have to keep working on it. Thank you for looking does the code look correct to you? Will try it out side of my project to try and make sure I am coding it correctly ?