0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【HTML】リストについて簡単に整理

Last updated at Posted at 2021-04-24

HTMLで使われるリスト

本記事ではHTMLで使われるリストについて、私が勉強した範囲で簡単にですが、記録しておきます。
※2021/5/31 説明リストについて追記

1.普通のリスト(liタグだけでの使用はNG)

<li> </li>タグで囲むとリストとして箇条書きで羅列される。
単純にこれだけの記載はあまり使わないのでしょうか。

<li>ノート</li>
<li>鉛筆</li>
<li>消しゴム</li>
<li>定規</li>

結果は以下。
1.PNG

2.順序なし ul要素、順序あり ol要素

<li> </li>タグで作っているリストを<ul> </ul>タグで囲むと、順序なしのリストになる。
・ul:Unordered Listの略

<ul>
  <li>ノート</li>
  <li>鉛筆</li>
  <li>消しゴム</li>
  <li>定規</li>
</ul>

結果は以下。
見た目的には1.の単純なリストとあまり変わらない印象。
2.PNG

次に、<li> </li>タグで作っているリストを<ol> </ol>タグで囲むと、順序ありのリストになる。
・ol:ordered Listの略

<ol>
  <li>ノート</li>
  <li>鉛筆</li>
  <li>消しゴム</li>
  <li>定規</li>
</ol>

結果は以下。
各項目の頭に番号がついた。
3.PNG

3.入れ子にしたリスト

下記のような書き方をすれば、入れ子として使うこともできる。
ulとolを混ぜて使うことも可能。

<ul>
  <li>ノート</li>
  <li>
    鉛筆
    <ol>
      <li>HB</li>
      <li>B</li>
      <li>2B</li>
    </ol>
  <li>消しゴム</li>
  <li>定規</li>
  </li>
</ul>

結果は以下。
4.PNG

3.説明リスト

用語とその説明をリスト化したもの。
複数の<dt>要素に対して一つの<dd>要素とすることもできる。

<dl>
  <dt>Firefox</dt>
  <dt>Mozilla Firefox</dt>
  <dt>Fx</dt>
  <dd>
    A free, open source, cross-platform,
    graphical web browser developed by the
    Mozilla Corporation and hundreds of
    volunteers.
  </dd>
</dl>

結果は以下。
<dd>要素で囲った説明内容が少しインデントされて表示される。

5.PNG

こんな感じで理解しています。
これからも勉強記録として記事を書きたいと思うので、認識違いなどがあれば、コメントいただけますと幸いです。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?