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.


Konrad Pilch
Konrad Pilch
2,435 Points

How can i make my height and width..


I have a situation that i believe its attendable.

So what im trying to do it to have my image thats 100%(300px) width and like 300px height and when you resize the browser to a macbook , tablet, mobile, the image will be allways square and the height willl change. I tried many things but i believe its has to do with JS ?

1 Answer

Hi Konrad,

Define max-width 100% in your CSS. This way, the image will automatically resize depending on the browser window. So it will work on all screen sizes etc. I think this code might be a solution for you:

img {
    max-width: 100%;
    height: auto;
Konrad Pilch
Konrad Pilch
2,435 Points

HI, thank yo for reply.

Oh , i forget to tell you that i add it with CSS and i have to display the height otherwise it wont appear .

I tried that many times and a lot of other things too . I see quite often , maybe? sites like that but i cant find any solution for it .