Why does the HTML5 DOCTYPE mess with my padding?

前端 未结 8 1312
灰色年华
灰色年华 2021-01-31 16:25

I have an html5 page with a navbar. Completely scratch coded. I just recently added a doctype to the item, and now I’m getting extra space under my navbar. If I remove the docty

相关标签:
8条回答
  • 2021-01-31 16:56

    I had the same problem when upgrading a XHTML4 website to HTML5. I had lots of these:

    <a><img></a>
    

    Which ended up with the magical extra padding around the images. For me the solution was simple -- add this css:

    img { vertical-align: top; }
    
    0 讨论(0)
  • 2021-01-31 16:56

    I've never used display: inline-block due to the IE7 issues, so I'm not familiar with its quirks. It seems like it's unnecessary to apply it to ul#pagetab in your situation, since it's not surrounded by inline elements. I would just convert it to a regular block element. Moreover, since it contains floated elements that do not need float beside some inline elements, I would just give ul#pagetab a real height via display: block; overflow: hidden;.

    This appears to resolve all your issues (which I can't account for in detail) and provides stylistically more appropriate styles.

    0 讨论(0)
提交回复
热议问题