I’m looking for a solution to fit a child div into it’s parent’s width.
Most solutions I’ve seen here are not cross-browser compatible (eg. display: table-cell; isn’t supported in IE <=8).

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The solution is to simply not declare
width: 100%.The default is
width: auto, which for block-level elements (such asdiv), will take the “full space” available anyway (different to howwidth: 100%does it).See: http://jsfiddle.net/U7PhY/2/
Just in case it’s not already clear from my answer: just don’t set a
widthon the childdiv.You might instead be interested in
box-sizing: border-box.