Why does the HTML5 DOCTYPE mess with my padding?

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

    I had the same problem with one of my sites. i found this answer here:

    "With an HTML5 doctype, images receive what seems to be the line-height attribute which text normally gets, and thus you get a “margin” underneath them. You can either set them to display:block or line-height:0, although I haven’t tested the latter enough to be sure it’s a good fix."

    I applied the line-height:0 to the

    which contained the navigation images. It did the trick for me.

提交回复
热议问题