Height: auto question

This is from Responsive Web Design Principles exercise 2, Make an Image Responsive. The max-width: 100%; line of code seems to solve the responsiveness issue without needing what the height: auto; code does in theory, which makes it so the image doesn’t get stretched I guess? But adding and commenting out that bit of code doesn’t appear to affect the exercise at all. What’s hilarious is that the exercise accepts it even if it’s commented out. What does it actually do?

The exercise didn’t accept it with height: auto; omitted. Check FCC’s github perhaps that wasn’t accounted for in the test.

Yeah, sorry, I meant adding that bit of code doesn’t affect the output of the exercise. I’ve finished the exercise in one piece and whatnot but am confused why height: auto was an important bit to include. Does the CSS default to height: auto and we just add it for best practice?

I think browser default is height: auto;. In the past browsers have been very different and it’s been a long time in the works get the makers to support open standards fully. Maybe it’s legacy IDK.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.