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

CSS

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Handling Pixel Density

Taking the SVG course earlier today reminded me of my Treehouse education earlier last year when I was taught about pixel density and how different screen resolutions affect Raster images.

Only I never really did much about it as it seemed too complicated at the time. Which means assets on my sites aren't really optimised for mobile beyond a bit of CSS width and height styling.

So I thought I'd ask again How do you handle images in different device pixel ratios. I think I remember something about a code snippet in which you swap images together but I can't remember how that's achieved. Maybe point me the way to the course that teaches it? :)

1 Answer

Hi Jonathan

I think, you mean this - SVG Basics, see "SVG and CSS" in second section ?

"SVG is an XML based language, and they can be embedded directly into HTML. This means their presentation can be adjusted with CSS, which allows SVGs to respond appropriately to different screen sizes."

-Salman

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,252 Points

Hi Salman, thanks for your reply and I'm sorry I'm so late replying. :)

No I'm talking about pixel; base image formats here and the holy grail in terms of how to handle images and how they're displayed in different device ratios :-)