Width and height control element dimensions, but responsive layouts usually prefer flexible constraints.
Preferred sizing tools
max-widthto prevent overflow.min-heightfor stable sections.width: 100%for fluid containers.
Pitfall
Hard fixed heights often clip translated text and dynamic content.
Important interview questions and answers
- Q: Why is
max-widthoften safer than fixed width?
A: It preserves responsiveness while limiting line length. - Q: Common issue with
height: 100%?
A: It depends on parent having explicit height context. - Q: How to avoid content clipping?
A: Prefer min-height plus natural content flow.
Pitfall: Check cascade order—author stylesheet loses to inline styles and !important surprises.