Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 90,705 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 90,705 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 :-)