Why
    adds extra top margin?

前端 未结 8 974
礼貌的吻别
礼貌的吻别 2020-12-01 23:47

I have a simple html page with some style in it and I do not understand why the adds some top margin?

Here is the source:

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 00:43

    as per this question Browsers' default CSS stylesheets

    add *{margin:0; padding:0;} which will remove default margin and padding given by browsers

    or you can also use reset.css

    * {
      margin: 0;
      padding: 0;
    }
    body {
      margin: 0;
      padding: 0;
      background-color: #ffffcc;
    }
    #content {
      width: 900px;
      margin-left: auto;
      margin-right: auto;
      border: 0;
      background-color: #ccccff;
    }

提交回复
热议问题