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 1 year has passed since last update.

【html】tableタグの使い方_列と行

Posted at

htmlのtableタグについてメモを残します。
今回は特に列と行について記述します。

【trとth(td)について】

trタグは列(縦の個数)を決定します。

th(td)タグは行(横の個数)を決定します。

コード1の場合、
trタグは1個なので列は1個になります。
thタグは3個なので行は3個になります。

コード1
html_code_ver1.png

コード1の実行結果が表示1になります。
表示1
html_view_ver1.png

コード2の場合、
trタグは3個なので列は3個になります。
thタグは1個(tr中の個数)なので行は1個になります。

コード2
html_code_ver2.png
表示2
html_view_ver2.png

【th:eachとtableタグ】

th:eachの要素をtableタグを使用して表示する方法を記述します。

コード3の場合、itemListの中身を横並び(列1個)に表示しています。
trタグは1個なので列は1個になります。
tdタグは1個ですが行は3個になります。
※itemListの要素数は表示3の通り3つになります。
tdタグはitemListの要素数分だけ行を表示します。

コード3

html_code_ver3.png

表示3
html_view_ver3.png

コード4の場合、itemListの中身を縦並び(列3個)に表示しています。
trタグは1個ですが列は3個になります。
tdタグは1個なので行は1個になります。

コード4
html_code_ver4.png
表示4
html_view_ver4.png

0
0
0

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?