Help us understand the problem. What is going on with this article?

HTML5でHeader上部の隙間を埋める

More than 3 years have passed since last update.

HTML5でコーディングをしていると最上部に隙間ができる時があるので、それの解消のために試したやり方

index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="style-home.css" type="text/css">
  <title>サンプルページ</title>
</head>
<body>
  <header>
    <nav>
      <ul class="ul-header">
        <li class="header-list">
          <a href="/" alt="トップページへ戻ります">
            <img src="rogo.png" width="150" height="60">
          </a>
        </li>
        <li class="header-list">リスト1</li>
        <li class="header-list">リスト2</li>
        <li class="header-list">リスト3</li>
        <li class="header-list">リスト4</li>
        <li class="header-list">リスト5</li>
        <li class="header-list">リスト6</li>
      </ul>
    </nav>
  </header>

  <!-- 中略 -->

</body>
</html>

CSSは下の形で記述

style-home.css
body {
  padding: 0;
  margin: 0;
}
header nav ul {
  height: 60px;
  margin-top: 0;
}
.header-list {
  height: 60px;
  float: left;
  list-style: none;
  text-align: right;
}

「header nav ul」セレクタは「.ul-header」に変更してもいいかもしれない。
「header nav ul」セレクタの高さの指定「height: 60px;」を取り除いた場合だと、この構造では上部の隙間が消えなかった。
どうやら高さの指定は必要らしい。構造にもよるのかもしれないけど。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away