Why does the HTML5 DOCTYPE mess with my padding?

前端 未结 8 1315
灰色年华
灰色年华 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:34

    It's because the DOCTYPE changes the rendering mode to Standards Compliance Mode. Specifically, this means you're using the W3C Box Model now which computes width/height for block elements differently than quirks mode.

    Read more here, here, and here.

提交回复
热议问题