When I remove the display:block from a p inside a div, it ignores the top-margin or it’s own hight or something like that. It snuggles up right next to the element above it. Does anyone know why?
The div is floated, the element above is not.
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.
Inline elements simply don’t take vertical margins or height into account. Block elements do.
Edit:
In response to comments, it looks like there are two issues at play here.
id='generals'. Change this toclass='generals'.overflow: hiddento yourgeneralsstyle. All of the elements inside it are floated, and so don’t apply to the height of the element. Addingoverflow: hiddenchanges how the element is displayed, clearing all the floats inside it.