Why
    adds extra top margin?

前端 未结 8 932
礼貌的吻别
礼貌的吻别 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;
    }
    <div id="content">
      <div>
        <ul>
          <li><a href="./xxx.html">xxx</a>
          </li>
          <li><a href="./yyy.html">yyy</a>
          </li>
          <li><a href="./zzzz.html">zzz</a>
          </li>
        </ul>
      </div>
    </div>

    0 讨论(0)
  • 2020-12-02 00:45

    It should be a user agent stylesheet. Your browser puts that margin on every <ul> element.

    Check here stackoverflow

    Also you can check here

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