<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HTML &#8211; Webサイト制作に関するノウハウブログ｜IWACODE</title>
	<atom:link href="https://iwacode-web.com/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>https://iwacode-web.com</link>
	<description>初心者でもわかりやすいようにWeb制作に関するノウハウを発信していきます。コーディングだけではなく、デザイン、WordPressに関する情報、フリーランスとしてのマインド、活動についても発信していきます。</description>
	<lastBuildDate>Thu, 16 Oct 2025 04:31:56 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://iwacode-web.com/wp-content/uploads/2023/12/cropped-site-icon-32x32.png</url>
	<title>HTML &#8211; Webサイト制作に関するノウハウブログ｜IWACODE</title>
	<link>https://iwacode-web.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>【JavaScript】現在のページに対応するナビゲーションメニューにスタイルを追加する方法</title>
		<link>https://iwacode-web.com/style-current-page/</link>
		
		<dc:creator><![CDATA[岩村　彰斗]]></dc:creator>
		<pubDate>Mon, 29 Jul 2024 05:42:10 +0000</pubDate>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web制作]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[コーディング]]></category>
		<guid isPermaLink="false">https://iwacode-web.com/?p=947</guid>

					<description><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/07/blog_20240729.jpg" class="webfeedsFeaturedVisual" /></p>皆さんこんにちは！IWACODEの岩村です！ 今回は現在のページに対応するナビゲーションメニューのリンクに対して、「このリンクが今のページですよ～」といった感じでスタイルを適用する方法を解説いたします。 実際によくあるヘ [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/07/blog_20240729.jpg" class="webfeedsFeaturedVisual" /></p>
<p>皆さんこんにちは！IWACODEの岩村です！</p>



<p>今回は現在のページに対応するナビゲーションメニューのリンクに対して、「このリンクが今のページですよ～」といった感じでスタイルを適用する方法を解説いたします。</p>



<p>実際によくあるヘッダーデザインを用いて解説していきます！</p>



<p>今回は以下のようなヘッダーを作成します。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1000" height="133" src="https://iwacode-web.com/wp-content/uploads/2024/07/image-21.png" alt="" class="wp-image-951" srcset="https://iwacode-web.com/wp-content/uploads/2024/07/image-21.png 1000w, https://iwacode-web.com/wp-content/uploads/2024/07/image-21-300x40.png 300w, https://iwacode-web.com/wp-content/uploads/2024/07/image-21-768x102.png 768w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>



<p>トップページを開いている想定なので、TOPの文字がオレンジになっています。</p>



<p>WORKSを開いたらWORKSの文字がオレンジに・・・といったような制御を行います。</p>



<h2 class="wp-block-heading">HTML/CSS/JavaScriptの例</h2>



<h3 class="wp-block-heading">HTML</h3>



<p>今回使用するデザインのHTMLを構築していきます。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;ja&quot;&gt;

&lt;head&gt;
  &lt;meta charset=&quot;UTF-8&quot;&gt;
  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
  &lt;title&gt;ナビゲーションメニューのスタイル&lt;/title&gt;
  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;
  &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.googleapis.com&quot;&gt;
  &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot; crossorigin&gt;
  &lt;link
    href=&quot;https://fonts.googleapis.com/css2?family=Caveat:wght@400..700&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap&quot;
    rel=&quot;stylesheet&quot;&gt;
&lt;/head&gt;

&lt;body&gt;
  &lt;header class=&quot;header&quot;&gt;
    &lt;h1 class=&quot;header__logo&quot;&gt;iwacode&lt;/h1&gt;
    &lt;nav class=&quot;header__nav&quot;&gt;
      &lt;ul class=&quot;header__nav-list&quot;&gt;
        &lt;li class=&quot;header__nav-item&quot;&gt;&lt;a href=&quot;index.html&quot;&gt;toppage&lt;/a&gt;&lt;/li&gt;
        &lt;li class=&quot;header__nav-item&quot;&gt;&lt;a href=&quot;about.html&quot;&gt;works&lt;/a&gt;&lt;/li&gt;
        &lt;li class=&quot;header__nav-item&quot;&gt;&lt;a href=&quot;services.html&quot;&gt;srevice&lt;/a&gt;&lt;/li&gt;
        &lt;li class=&quot;header__nav-item&quot;&gt;&lt;a href=&quot;contact.html&quot;&gt;contact&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/nav&gt;
  &lt;/header&gt;
  &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;

&lt;/html&gt;</code></pre></div>



<h3 class="wp-block-heading">CSS</h3>



<p>一番下に<span class="swl-marker mark_yellow">JavaScriptでクラスが付与された際のスタイル</span>を記載しています。<br>※<strong><span class="swl-marker mark_yellow">.is-active</span></strong>が付与された際の指定</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-css" data-lang="CSS"><code>/* スタイルの初期化 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  list-style-type: none;
  text-decoration: none;
}

/* サイトの基本設定 */
html {
  color: #465572;
  font-size: 16px;
  letter-spacing: 0.03em;
}

.header {
  align-items: center;
  background-color: #E9ECEF;
  display: flex;
  height: 80px;
  justify-content: space-between;
  padding: 0 40px;
}

.header__logo {
  font-family: &quot;Caveat&quot;, cursive;
  font-size: 2rem;
  font-weight: bold;
}

.header__nav {
  font-family: &quot;Roboto&quot;, sans-serif;
  font-size: .925rem;
}

.header__nav-list {
  display: flex;
  gap: 2em;
}

.header__nav-item&gt;a {
  color: #465572;
  font-weight: bold;
  display: block;
  transition: .3s;
}

.header__nav-item&gt;a:hover {
  color: #FF983A;
}

/* ↓↓↓↓↓　今回のポイント　↓↓↓↓↓ */
/* JavaScriptにて.is-activeクラスが付与された場合のスタイル */
.header__nav-item&gt;a.is-active {
  color: #FF983A;
}
/* ↑↑↑↑↑　今回のポイント　↑↑↑↑↑ */</code></pre></div>



<h3 class="wp-block-heading">JavaScriptの記載</h3>



<div class="hcb_wrap"><pre class="prism line-numbers lang-js" data-lang="JavaScript"><code>const currentPath = window.location.pathname;
const navLinks = document.querySelectorAll(&quot;.header__nav-item a&quot;);

navLinks.forEach(link =&gt; {
  if (link.href === currentPath) {
    link.classList.add(&quot;is-active&quot;);
  }
});</code></pre></div>



<h4 class="wp-block-heading">JavaScriptの解説</h4>



<p>分かりやすいよう１行ずつコメントを入れました。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-js" data-lang="JavaScript"><code>// １）定数currentPathに現在開いているページのURLを格納
const currentPath = window.location.pathname;

// ２）定数navLinksに.header__nav-item a に該当する要素を格納
// 　　複数取得できるので配列となる
const navLinks = document.querySelectorAll(&quot;.header__nav-item a&quot;);

// ３）２で取得した要素をループで処理する
navLinks.forEach(link =&gt; {

  // ４）ここでのlink.hrefはaタグのhref属性に指定しているURL
  // 　　currentPathには現在開いているページのURLが入っているので、
  // 　　if文の===で比較し、一致している要素の場合、中の処理に入る
  if (link.href === currentPath) {

    // ５）linkにis-activeクラスを付与
    // 　　※linkはaタグのこと
    link.classList.add(&quot;is-active&quot;);
  }
});</code></pre></div>



<p>処理の概要としては、aタグで指定しているURLと現在開いているページのURLを比較して、同一であれば、一致するhref属性を持つaタグに対して.is-activeクラスを付与するといったものになります。</p>



<h2 class="wp-block-heading">さいごに</h2>



<p>いかがでしたでしょうか。</p>



<p>上記の処理を行うことで、現在開いているページが閲覧している方も一目でわかるため、ページの回遊性にも繋がります。</p>



<p>比較的簡単なJavaScriptの処理で実装可能なため、仕様を理解しぜひ組み込んでいってください！</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【CSS】ファーストビューや画像上のテキストなど、要素を中央、真ん中に配置する方法</title>
		<link>https://iwacode-web.com/css-center-aligned/</link>
		
		<dc:creator><![CDATA[岩村　彰斗]]></dc:creator>
		<pubDate>Fri, 12 Jul 2024 11:17:46 +0000</pubDate>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Web制作]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[コーディング]]></category>
		<guid isPermaLink="false">https://iwacode-web.com/?p=911</guid>

					<description><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/07/blog_20240712-1.jpg" class="webfeedsFeaturedVisual" /></p>皆さんこんにちは！IWACODEの岩村です。 今回はHTML/CSSコーディングにおいて避けては通れない、要素の真ん中寄せについて解説いたします。 真ん中寄せはWEBサイト上でかなりの頻度で実装する必要があるということと [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/07/blog_20240712-1.jpg" class="webfeedsFeaturedVisual" /></p>
<p>皆さんこんにちは！IWACODEの岩村です。</p>



<p>今回はHTML/CSSコーディングにおいて避けては通れない、要素の真ん中寄せについて解説いたします。</p>



<p>真ん中寄せはWEBサイト上でかなりの頻度で実装する必要があるということと、仕組みについて理解することで、コーディングの知識が大きく高まるのかなと個人的には感じております。</p>



<p>今回記事を読んでいただくことによって、もう真ん中寄せでは悩まなくなると思います！</p>



<p>ぜひ最後まで読んでいただけると嬉しいです！</p>



<h2 class="wp-block-heading">真ん中寄せをする方法について</h2>



<p>真ん中寄せをする方法は大きくわけて４つ方法があり、それぞれ解説させていただきます！</p>



<figure class="wp-block-image size-full"><img decoding="async" width="542" height="335" src="https://iwacode-web.com/wp-content/uploads/2024/07/image-3.png" alt="" class="wp-image-913" srcset="https://iwacode-web.com/wp-content/uploads/2024/07/image-3.png 542w, https://iwacode-web.com/wp-content/uploads/2024/07/image-3-300x185.png 300w" sizes="(max-width: 542px) 100vw, 542px" /></figure>



<h3 class="wp-block-heading">display:flexを使用する方法</h3>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;div class=&quot;box wrap&quot;&gt;
  &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;style&gt;
  .box {
    width: 500px;
    height: 300px;
    background-color: rgb(209, 252, 245);
  }

  .item {
    background-color: rgb(0, 200, 200);
    width: 100px;
    height: 100px;
  }

  .wrap {
    display: flex;
    justify-content: center;
    align-items: center;
  }
&lt;/style&gt;</code></pre></div>



<p>wrapクラスに以下のCSSを適用しています。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-css" data-lang="CSS"><code>.wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}</code></pre></div>



<p>まずはwrapクラスの要素に対して、<strong>display:flex</strong>を適用させます。<br>そうすることによって<span class="swl-marker mark_yellow">子要素（.item）がflexボックス</span>として操作できるようになります。<br>これを利用し、<strong>justify-content: center</strong>で水平方向（←→）に対して真ん中寄せ、<strong>align-items: center</strong>; で垂直方向（↑↓）に対して真ん中寄せを行い、結果的に真ん中寄せを実現させています。</p>



<p>この方法でも特に問題はないのですが、真ん中寄せのためにCSSを３行使用しているため、可能であればもっと短い記載で実現させたいところです。<br>ということで次の方法が個人的にはオススメです！</p>



<h3 class="wp-block-heading">display:gridを使用する方法</h3>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;div class=&quot;box wrap&quot;&gt;
  &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;style&gt;
  .body {
    padding: 40px;
  }

  .box {
    width: 500px;
    height: 300px;
    background-color: rgb(209, 252, 245);
  }

  .item {
    background-color: rgb(0, 200, 200);
    width: 100px;
    height: 100px;
  }

  .wrap {
    display: grid;
    place-items: center;
  }
&lt;/style&gt;
</code></pre></div>



<p>wrapクラスに以下のCSSを適用しています。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-css" data-lang="CSS"><code>  .wrap {
    display: grid;
    place-items: center;
  }</code></pre></div>



<p>こちらでは上記の2行で真ん中寄せが実現可能です。</p>



<p><span class="swl-marker mark_yellow"><strong>display:grid</strong>にてgridレイアウト化</span>し、<strong>place-item: center</strong>でgridコンテンツかしている要素（.item）を真ん中に寄せています。</p>



<p>コーディングを行う上で、<span class="swl-marker mark_yellow"><strong>この方法が一番記述が短く、楽に実現ができる</strong></span>のでかなりオススメな方法になります！</p>



<h3 class="wp-block-heading">positionを使用する方法</h3>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;div class=&quot;box wrap&quot;&gt;
  &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;style&gt;
  .body {
    padding: 40px;
  }

  .box {
    width: 500px;
    height: 300px;
    background-color: rgb(209, 252, 245);
  }

  .item {
    background-color: rgb(0, 200, 200);
    width: 100px;
    height: 100px;
  }

  .wrap {
    position: relative;
  }

  .wrap .item {
    position: absolute;
    inset: 0; /* top: 0; right: 0; bottom: 0; left: 0; の略 */
    margin: auto;
  }
&lt;/style&gt;</code></pre></div>



<p>wrapクラスに<strong>position: relative</strong>を指定し、positionの基点にします。<br>子要素である.itemに対して、<strong>position: absolute; inset: 0; margin: auto; </strong>を指定します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-css" data-lang="CSS"><code>  .wrap {
    position: relative;
  }

  .wrap .item {
    position: absolute;
    inset: 0; /* top: 0; right: 0; bottom: 0; left: 0; の略 */
    margin: auto;
  }</code></pre></div>



<p>こちらの方法でも真ん中寄せにはできるのですが、ちょっと記載量が多いです・・・</p>



<p><strong>inset</strong>プロパティはpositionプロパティと併用して使用する、top/right/bottom/leftのショートハンドプロパティです。</p>



<p><span class="swl-marker mark_yellow">上下左右に値を0</span>で指定し、さらに<span class="swl-marker mark_yellow">上下左右の余白をauto</span>にすることで、.itemを真ん中寄せにしています。</p>



<p>通常真ん中寄せにするのであれば、display:flexやdisplay:gridで指定する方がすっきりしますし見やすいのでそちらをオススメします。</p>



<p>ですが、<span class="swl-marker mark_yellow">子要素の方が親要素より大きい場合、上記の方法では実装ができません。</span></p>



<p>次に実装する方法では、親要素より子要素が大きい場合でも、真ん中寄せにすることが可能です。</p>



<h3 class="wp-block-heading">positionを使用する方法（親要素より子要素が大きい場合）</h3>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;div class=&quot;box wrap&quot;&gt;
  &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;style&gt;
  .body {
    padding: 40px;
  }

  .box {
    width: 500px;
    height: 300px;
    background-color: rgb(209, 252, 245);
  }

  .item {
    background-color: rgb(0, 200, 200);
    width: 100px;
    height: 100px;
  }

  .wrap {
    position: relative;
  }

  .wrap .item {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
  }
&lt;/style&gt;</code></pre></div>



<p>wrapクラスに<strong>position: relative</strong>を指定し、positionの基点にします。<br>子要素である.itemに対して、<strong>position: absolute; inset: 50% auto auto 0; transform: translate(-50%, -50%); </strong>を指定します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-css" data-lang="CSS"><code>  .wrap {
    position: relative;
  }

  .wrap .item {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
  }</code></pre></div>



<p>これを説明すると、insetプロパティにてtop: 50%,left50%で.itemを移動させます。この状態では以下のようになります。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="769" height="473" src="https://iwacode-web.com/wp-content/uploads/2024/07/image-6.png" alt="" class="wp-image-918" style="width:537px;height:auto" srcset="https://iwacode-web.com/wp-content/uploads/2024/07/image-6.png 769w, https://iwacode-web.com/wp-content/uploads/2024/07/image-6-300x185.png 300w" sizes="(max-width: 769px) 100vw, 769px" /></figure>



<p>これでは不完全なので、transform: translate(-50%, -50%);の指定で、.itemの縦横の半分の大きさ（-50%）だけずらして調節します。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="774" height="473" src="https://iwacode-web.com/wp-content/uploads/2024/07/image-7.png" alt="" class="wp-image-919" style="width:550px;height:auto" srcset="https://iwacode-web.com/wp-content/uploads/2024/07/image-7.png 774w, https://iwacode-web.com/wp-content/uploads/2024/07/image-7-300x183.png 300w, https://iwacode-web.com/wp-content/uploads/2024/07/image-7-768x469.png 768w" sizes="(max-width: 774px) 100vw, 774px" /></figure>



<p>この方法であれば、もし子要素が親要素より大きい場合でも対応ができるため、より汎用的に対応が可能です！</p>



<h2 class="wp-block-heading">さいごに</h2>



<p>今回は真ん中寄せについて４種類解説させていただきました。</p>



<p>最後に解説した方法だけで特に困ることはないのですが、コードが長くなると複雑になってわかりにくくなってしまうため、出来るだけ簡潔にコーディングを済ませたいところです。</p>



<p>そのため、可能な範囲でdisplay:gridなどで調節できるとよりきれいにコーディングが進めれると思います！</p>



<p>今回の記事が少しでも参考になりましたら幸いです。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【HTML】TABLEタグで線が2重になる-線が重ならないとき</title>
		<link>https://iwacode-web.com/table-border-collapse/</link>
		
		<dc:creator><![CDATA[岩村　彰斗]]></dc:creator>
		<pubDate>Thu, 11 Jul 2024 12:26:30 +0000</pubDate>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Web制作]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[コーディング]]></category>
		<category><![CDATA[初心者向け]]></category>
		<guid isPermaLink="false">https://iwacode-web.com/?p=902</guid>

					<description><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/07/blog_20240711.jpg" class="webfeedsFeaturedVisual" /></p>皆さんこんにちは！IWACODEの岩村です。 今回はTABLEタグの罫線について解説いたします。 WEBサイト上で料金表や時間割などの表を作成する際に使用するTABLEタグですが、 TABLEタグで罫線を引いたとき以下の [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/07/blog_20240711.jpg" class="webfeedsFeaturedVisual" /></p>
<p>皆さんこんにちは！IWACODEの岩村です。</p>



<p>今回はTABLEタグの罫線について解説いたします。</p>



<p>WEBサイト上で料金表や時間割などの表を作成する際に使用するTABLEタグですが、</p>



<p>TABLEタグで罫線を引いたとき以下のような表示になったことはないでしょうか。TABLEタグにはとあるプロパティの初期値の影響で、borderプロパティで罫線を引くと以下のような状態になってしまいます。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="531" height="210" src="https://iwacode-web.com/wp-content/uploads/2024/07/image.png" alt="" class="wp-image-903" srcset="https://iwacode-web.com/wp-content/uploads/2024/07/image.png 531w, https://iwacode-web.com/wp-content/uploads/2024/07/image-300x119.png 300w" sizes="(max-width: 531px) 100vw, 531px" /></figure>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>  &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;見出し&lt;/th&gt;
      &lt;th&gt;見出し&lt;/th&gt;
      &lt;th&gt;見出し&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;

  &lt;style&gt;
    table {
      width: 500px;
    }

    th,
    td {
      padding: 1em 0;
      background-color: #eee;
      border: 1px solid #999;
    }

    td {
      text-align: center;
    }
  &lt;/style&gt;</code></pre></div>



<h2 class="wp-block-heading">border-collapseプロパティについて</h2>



<p>セルとセルの間に謎の間隔が生まれるのは、TABLEタグの<strong>border-collapse</strong>プロパティが影響しています。</p>



<p><strong>border-collapse</strong>プロパティの値が<span class="swl-marker mark_yellow">初期値では<strong><span class="swl-inline-color has-swl-deep-01-color">separate</span></strong></span>になっているため間隔があいています。</p>



<p>間隔を埋めるためにはTABLEタグに以下のように指定します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>  &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;見出し&lt;/th&gt;
      &lt;th&gt;見出し&lt;/th&gt;
      &lt;th&gt;見出し&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;

  &lt;style&gt;
    table {
      width: 500px;
      border-collapse: collapse;  /* 追加 */
    }

    th,
    td {
      padding: 1em 0;
      background-color: #eee;
      border: 1px solid #999;
    }

    td {
      text-align: center;
    }
 &lt;/style&gt;</code></pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="538" height="200" src="https://iwacode-web.com/wp-content/uploads/2024/07/image-1.png" alt="" class="wp-image-905" srcset="https://iwacode-web.com/wp-content/uploads/2024/07/image-1.png 538w, https://iwacode-web.com/wp-content/uploads/2024/07/image-1-300x112.png 300w" sizes="(max-width: 538px) 100vw, 538px" /></figure>



<div class="hcb_wrap"><pre class="prism line-numbers lang-css" data-lang="CSS"><code>border-collapse: collapse;</code></pre></div>



<p>このプロパティ、値を指定することで、セルとセル間の間隔を消すことができます。</p>



<p>セルとセルの線が重なって見栄えがスッキリしますね。</p>



<h2 class="wp-block-heading">セルとセルの間隔を空けて見せるには</h2>



<p>WEBサイトのデザインにもよりますが、基本的にTABLEタグでは<strong><span class="swl-marker mark_yellow">border-collapse: collapse</span></strong>で指定してコーディングすることが多いです。</p>



<p>セルとセルの間隔があいているような表をデザインすることもありますが、そのような場合でも<strong><span class="swl-marker mark_yellow">border-collapse: collapse</span></strong>を指定して、罫線を白にするなど間隔があいているように見せることもできます。</p>



<p>以下はborderプロパティで白線で間隔を空けています。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="532" height="204" src="https://iwacode-web.com/wp-content/uploads/2024/07/image-2.png" alt="" class="wp-image-907" srcset="https://iwacode-web.com/wp-content/uploads/2024/07/image-2.png 532w, https://iwacode-web.com/wp-content/uploads/2024/07/image-2-300x115.png 300w" sizes="(max-width: 532px) 100vw, 532px" /></figure>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>  &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;見出し&lt;/th&gt;
      &lt;th&gt;見出し&lt;/th&gt;
      &lt;th&gt;見出し&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
      &lt;td&gt;内容&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;

  &lt;style&gt;
    table {
      width: 500px;
      border-collapse: collapse;
      /* 追加 */
    }

    th,
    td {
      padding: 1em 0;
      border: 3px solid #fff;
    }

    th {
      background-color: bisque;
    }

    td {
      text-align: center;
      background-color: #f5f5f5;
    }
  &lt;/style&gt;</code></pre></div>



<p>このように記載することによって間隔を空けて見せることも可能です。</p>



<h2 class="wp-block-heading">さいごに</h2>



<p>今回はborder-collapseについて解説いたしました。</p>



<p>初心者のうちはハマりやすいところでもあるので、TABLEタグを使用する際にはぜひ参考にしていただければと思います。</p>



<p>TABLEタグについては以下の記事でも解説しております。</p>



<p>少しでも参考になれば幸いです♪</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240221-300x169.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://iwacode-web.com/html-tabletag-join/" data-wpel-link="internal">【初心者向け】tableタグの使い方！部分的に結合、セルを結合した表を作成する</a>
						<span class="p-blogCard__excerpt">こんにちは。IWACODEの岩村彰斗です。 今回はtableタグの使い方ということで、部分的に結合された表の作成方法について解説させていただきます。 見出しなどが2行になっ&#8230;</span>					</div>
				</div>
			</div>
		</div>

<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240219-1-300x169.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://iwacode-web.com/tabletag-how-to/" data-wpel-link="internal">tableタグは使わない？どんな時に使う？使用するケースについて解説</a>
						<span class="p-blogCard__excerpt">こんにちは。IWACODEの岩村彰斗です。 今回はtableタグについて、どのようなときに使用するのが良いのか、tableタグを使用しない場合はどのようにするのかについて解説&#8230;</span>					</div>
				</div>
			</div>
		</div>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【フリーランス/WEBデザイナー】コーディングができないとダメなのか &#8211; HTML/CSS/JavaScriptの勉強</title>
		<link>https://iwacode-web.com/webdesign-htmlcss-coding/</link>
		
		<dc:creator><![CDATA[岩村　彰斗]]></dc:creator>
		<pubDate>Fri, 31 May 2024 10:42:30 +0000</pubDate>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Web制作]]></category>
		<category><![CDATA[YouTube]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[コーディング]]></category>
		<guid isPermaLink="false">https://iwacode-web.com/?p=896</guid>

					<description><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/05/サムネイル.jpg" class="webfeedsFeaturedVisual" /></p>こんにちは！IWACODEのいわむらあきとです。 今回はYouTubeでフリーランスのWEBデザイナーはコーディング（HTML/CSS）ができないとダメなのかということをテーマにおいて、お話しております。 「フリーランス [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/05/サムネイル.jpg" class="webfeedsFeaturedVisual" /></p>
<p>こんにちは！IWACODEのいわむらあきとです。</p>



<p>今回はYouTubeでフリーランスのWEBデザイナーはコーディング（HTML/CSS）ができないとダメなのかということをテーマにおいて、お話しております。</p>



<p>「フリーランス」として活動する上で、どのような立ち位置で、どのような仕事を取っていくかによっても方向性が変わってきます。</p>



<p>WEBデザイナーの方で、</p>



<p>コーディングには手を付けていない方</p>



<p>苦手だから今後どうしようかな</p>



<p>といった方はぜひチェックをしてみてください。</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="【フリーランスのWEBデザイナー】コーディングができないとダメなのか" width="500" height="281" src="https://www.youtube.com/embed/ieeV2Z5hrJI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>本ブログ内でも記事にしておりますので、よろしければこちらもご覧ください。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240228-300x169.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://iwacode-web.com/freelance-webdesigner-coding/" data-wpel-link="internal">フリーランスのWEBデザイナーにコーディングスキルは必要なのか？</a>
						<span class="p-blogCard__excerpt">こんにちは！IWACODEの岩村彰斗です。 今回はフリーランスのWEBデザイナーに、コーディングスキルはあったほうがよいのか？について考えてみました。 コーディングとい&#8230;</span>					</div>
				</div>
			</div>
		</div>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【VSCODE】【効率化】入れておくと便利なおすすめプラグイン！</title>
		<link>https://iwacode-web.com/vscode-useful-plugin/</link>
		
		<dc:creator><![CDATA[岩村　彰斗]]></dc:creator>
		<pubDate>Sun, 25 Feb 2024 02:03:10 +0000</pubDate>
				<category><![CDATA[Tool]]></category>
		<category><![CDATA[Web制作]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[vscode]]></category>
		<category><![CDATA[コーディング]]></category>
		<guid isPermaLink="false">https://iwacode-web.com/?p=769</guid>

					<description><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240225.jpg" class="webfeedsFeaturedVisual" /></p>こんにちは！IWACODEの岩村彰斗です。 今回はWeb制作や開発で使用するVisual Studio Code（以下、VSCODE）のおすすめプラグインについてご紹介させていただきます！ もし入れていないプラグインがあ [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240225.jpg" class="webfeedsFeaturedVisual" /></p>
<p>こんにちは！IWACODEの岩村彰斗です。</p>



<p>今回はWeb制作や開発で使用するVisual Studio Code（以下、VSCODE）のおすすめプラグインについてご紹介させていただきます！</p>



<p>もし入れていないプラグインがありましたら参考にして頂けると幸いです。</p>



<p class="is-style-icon_info"><strong>プラグインとは？</strong><br>VSCODEなどの「ソフトウェアやアプリケーション」で、機能を追加するための拡張プログラムになります。標準にはない機能を追加することによって、使い勝手が向上し作業効率も上がります。</p>



<h2 class="wp-block-heading">プラグインのインストール方法</h2>



<h3 class="wp-block-heading">はじめに</h3>



<h4 class="wp-block-heading">プラグインのインストール方法について</h4>



<p>VSCODEを起動し、左のサイドバーよりインストールを行います。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1000" height="549" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-9.png" alt="" class="wp-image-770" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-9.png 1000w, https://iwacode-web.com/wp-content/uploads/2024/02/image-9-300x165.png 300w, https://iwacode-web.com/wp-content/uploads/2024/02/image-9-768x422.png 768w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>



<p>プラグインのマークをクリックし、プラグインを検索します。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1000" height="743" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-11.jpg" alt="" class="wp-image-772" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-11.jpg 1000w, https://iwacode-web.com/wp-content/uploads/2024/02/image-11-300x223.jpg 300w, https://iwacode-web.com/wp-content/uploads/2024/02/image-11-768x571.jpg 768w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>



<p>インストールしたいプラグインをクリックし、インストールボタンを押すとインストールが始まります。</p>



<h4 class="wp-block-heading">注意点</h4>



<p>プラグインはインストール後、ソフトの再起動が必要な場合があります。その場合はVSCODEを一旦閉じて、再度起動してあげるとプラグインが有効となります。</p>



<h2 class="wp-block-heading">おすすめプラグイン</h2>



<h3 class="wp-block-heading">まず入れておきたいプラグイン</h3>



<h4 class="wp-block-heading">Japanese Language Pack</h4>



<p>VSCODEは英語表記のため、日本語で表示してほしいといった方向けのプラグインになります。</p>



<h4 class="wp-block-heading">Auto Close Tag</h4>



<p>開始タグを記載すると、閉じタグが自動で付いてくれます。</p>



<p>例えば&lt;p>と打つと、&lt;/p>も自動で記載されます。閉じタグの記載漏れも減るので、とても便利です！</p>



<h4 class="wp-block-heading">Auto Rename Tag</h4>



<p>開始タグの名前を変更すると、終了タグも合わせて変更してくれます。</p>



<p>例えば、&lt;p>・・・&lt;/p>を&lt;div>に変更した場合、開始タグの名前を変更するだけで、終了タグも変更してくれます。</p>



<p>変更漏れも防げるのでとても便利です！</p>



<h3 class="wp-block-heading">入れておくと見やすくなる（視認性が上がる）プラグイン</h3>



<h4 class="wp-block-heading">Color Highlight</h4>



<p>色コードの背景色が指定した色になり、設定した色が分かりやすくなります！</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="697" height="160" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-11.png" alt="" class="wp-image-775" style="width:500px" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-11.png 697w, https://iwacode-web.com/wp-content/uploads/2024/02/image-11-300x69.png 300w" sizes="(max-width: 697px) 100vw, 697px" /></figure>



<h4 class="wp-block-heading">Indent-Rainbow</h4>



<p>インデントが色分けされて階層がより見やすくなります。</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" width="580" height="194" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-12.png" alt="" class="wp-image-776" style="width:498px" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-12.png 580w, https://iwacode-web.com/wp-content/uploads/2024/02/image-12-300x100.png 300w" sizes="(max-width: 580px) 100vw, 580px" /></figure>
</div>


<h4 class="wp-block-heading">zenkaku</h4>



<p>小文字と大文字を識別してくれます。打ち間違えてそのままにするケースがなくなるため、非常に助かります。</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" width="445" height="95" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-14.png" alt="" class="wp-image-778" style="width:500px" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-14.png 445w, https://iwacode-web.com/wp-content/uploads/2024/02/image-14-300x64.png 300w" sizes="(max-width: 445px) 100vw, 445px" /></figure>
</div>


<h4 class="wp-block-heading">Trailing Spaces</h4>



<p>コードの末尾に余分なスペースなどが入っている場合に、わかるようになります。</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" width="523" height="89" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-13.png" alt="" class="wp-image-777" style="width:497px" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-13.png 523w, https://iwacode-web.com/wp-content/uploads/2024/02/image-13-300x51.png 300w" sizes="(max-width: 523px) 100vw, 523px" /></figure>
</div>


<h3 class="wp-block-heading">入れておくと効率化が図れる便利なプラグイン</h3>



<h4 class="wp-block-heading">Live Server</h4>



<p>VSCODEの変更内容をリアルタイムでブラウザに反映できます。</p>



<p>ローカルサーバとして起動させることができ、VSCODEで保存すると自動的に変更内容が反映されるため、大変効率よくコーディングすることが可能です。</p>



<p>HTMLファイルをchromeなどのブラウザにドラッグアンドドロップする必要もなくなります。</p>



<h4 class="wp-block-heading">CSS Peek</h4>



<p>クラス名にカーソルを合わせて、F12を押すことで定義しているところを表示（ジャンプ）してくれます。</p>



<p>どのようなCSSプロパティがどこで定義されているかすぐわかります！</p>



<p>Alt（Option）+ F12キーでジャンプせずにその場に表示させることも可能なため、行ったり来たりする必要もないです。</p>



<h4 class="wp-block-heading">IntelliSense for CSS class names in HTML</h4>



<p>すでにclassとしてCSSに定義している場合、HTMLに記載する際に自動補完されます。</p>



<p>キーを打っている際に、自動で候補として挙がってくるため、効率よくコードの記載が可能になります。</p>



<h4 class="wp-block-heading">htmltagwrap</h4>



<p>選択したテキストをHTMLタグで囲むことができます。</p>



<p>コードを選択して、Alt（Option） + Wを押すことによって、自動的に開始終了タグが生成されるため、非常に便利です！</p>



<p>デフォルトのタグが&lt;p>になっているので、こちら好みにはなりますが、プラグインの設定画面から変更することが可能です。</p>



<p>コーディングをしていて、レイアウトによっては「この要素に対して親要素を追加したい…」といった場面に遭遇したことはないでしょうか？</p>



<p>コードの量が少なければそれほど手間ではないですが、複数の要素を一気にとなると、下手すると1画面に収まらない場合もあるので、そういった場合に非常に便利です。</p>



<figure class="wp-block-video"><video height="320" style="aspect-ratio: 752 / 320;" width="752" autoplay controls loop muted src="https://iwacode-web.com/wp-content/uploads/2024/02/20240225-01.mp4" playsinline></video></figure>



<h2 class="wp-block-heading">さいごに</h2>



<p>いかがでしたでしょうか？</p>



<p>プラグインをインストールすることによって、作業時間の短縮や、品質をあげることが可能です。</p>



<p>もし使用していないプラグインや、困っていることが解決できそうなプラグインがありましたら是非お試しください。</p>



<p>今回の記事が少しでも参考になりましたら幸いです。</p>
]]></content:encoded>
					
		
		<enclosure url="http://iwacode-web.com/wp-content/uploads/2024/02/20240225-01.mp4" length="39364" type="video/mp4" />

			</item>
		<item>
		<title>【初心者向け】tableタグの使い方！部分的に結合、セルを結合した表を作成する</title>
		<link>https://iwacode-web.com/html-tabletag-join/</link>
					<comments>https://iwacode-web.com/html-tabletag-join/#respond</comments>
		
		<dc:creator><![CDATA[岩村　彰斗]]></dc:creator>
		<pubDate>Wed, 21 Feb 2024 02:24:09 +0000</pubDate>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Web制作]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[コーディング]]></category>
		<category><![CDATA[初心者向け]]></category>
		<guid isPermaLink="false">https://iwacode-web.com/?p=698</guid>

					<description><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240221.jpg" class="webfeedsFeaturedVisual" /></p>こんにちは。IWACODEの岩村彰斗です。 今回はtableタグの使い方ということで、部分的に結合された表の作成方法について解説させていただきます。 tableタグの使い方が分からないといった方は、以下の記事で基本的な記 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240221.jpg" class="webfeedsFeaturedVisual" /></p>
<p>こんにちは。IWACODEの岩村彰斗です。</p>



<p>今回はtableタグの使い方ということで、部分的に結合された表の作成方法について解説させていただきます。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>見出しなどが2行になっている表ですね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>tableタグを使用することで、簡単に実装が可能なのでぜひ覚えていってください。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p>tableタグの使い方が分からないといった方は、以下の記事で基本的な記載方法をご紹介しております。ご参考いただけますと幸いです。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240220-300x169.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://iwacode-web.com/html-tabletag-beginner/" data-wpel-link="internal">【初心者向け】tableタグの使い方！tr/th/tdなど基本的を覚えてなレイアウトを作成する</a>
						<span class="p-blogCard__excerpt">こんにちは。IWACODEの岩村彰斗です。 今回はtableタグについて、初心者の方向けに、基本的なコーディング方法について解説いたします。 tableタグって、trとかthとかい&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h2 class="wp-block-heading">tableタグで結合する方法</h2>



<p>結合を行う際にはthタグ、もしくはtdタグに以下の記載を行います。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;!-- 横方向に結合する場合 --&gt;
&lt;th colspan=&quot;2&quot;&gt;&lt;/th&gt;

&lt;!-- 縦方向に結合する場合 --&gt;
&lt;td rowspan=&quot;2&quot;&gt;&lt;/td&gt;</code></pre></div>


<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p><strong>colspan</strong>と<strong>rowspan</strong>を記載するんですね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>結合する際には、タグの<strong>属性</strong>として、<strong>開始タグの中に記載</strong>します。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p>colspanとrowspanに「=2」と記載しているのは、2列（col）、または2行（row）結合するかを表しています。</p>



<p><span class="swl-marker mark_yellow">colspanでは何列分</span>広げるか、<span class="swl-marker mark_yellow">rowspanでは何行分</span>広げるかを想像していただけると、わかりやすいかと思います。</p>



<h2 class="wp-block-heading">tableタグを使用した表を作成</h2>



<h3 class="wp-block-heading">見出し部分が結合されたレイアウト</h3>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="631" height="268" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-4.png" alt="" class="wp-image-711" style="width:500px" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-4.png 631w, https://iwacode-web.com/wp-content/uploads/2024/02/image-4-300x127.png 300w" sizes="(max-width: 631px) 100vw, 631px" /></figure>


<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>今回はこのような表を作成していきます。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>見出しが２行、２列になっていますね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>２行になっている部分は、colspanとrowspanを使用して作成します。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>  &lt;table&gt;
    &lt;thead&gt;
      &lt;!-- 1行目 --&gt;
      &lt;tr&gt;
        &lt;th colspan=&quot;2&quot; rowspan=&quot;2&quot;&gt;&lt;/th&gt;
        &lt;th colspan=&quot;2&quot;&gt;a&lt;/th&gt;
        &lt;th colspan=&quot;2&quot;&gt;b&lt;/th&gt;
      &lt;/tr&gt;
      &lt;!-- 2行目 --&gt;
      &lt;tr&gt;
        &lt;th&gt;a1&lt;/th&gt;
        &lt;th&gt;a2&lt;/th&gt;
        &lt;th&gt;b1&lt;/th&gt;
        &lt;th&gt;b2&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;

    &lt;tbody&gt;
      &lt;!-- 3行目 --&gt;
      &lt;tr&gt;
        &lt;th rowspan=&quot;2&quot;&gt;c&lt;/th&gt;
        &lt;th&gt;c1&lt;/th&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;!-- 4行目 --&gt;
      &lt;tr&gt;
        &lt;th&gt;c2&lt;/th&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;!-- 5行目 --&gt;
      &lt;tr&gt;
        &lt;th rowspan=&quot;2&quot;&gt;d&lt;/th&gt;
        &lt;th&gt;d1&lt;/th&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;!-- 6行目 --&gt;
      &lt;tr&gt;
        &lt;th&gt;d2&lt;/th&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

  &lt;style&gt;
    thead {
      background-color: #2CA5FF;
      color: #fff;
    }

    th,
    td {
      border-collapse: collapse;
      border: 3px solid #fff;
      padding: 10px;
      text-align: center;
      width: 100px;
    }

    tbody {
      color: #555;
      font-weight: 700;
    }

    tbody th {
      background-color: #2CD9FF;
    }

    tbody td {
      background-color: #FFF8DF;
    }
  &lt;/style&gt;</code></pre></div>



<p>１行目の記載にcolspan=2が３つ入っております。これで２列分の要素を３つ作成しております。</p>



<p>内容部分の１列目は２行分広げる必要があるため、rowspan=2を指定しています。３行目と５行目の１列目にあたる要素に指定しております。</p>



<p>左上の２行２列分枠を取っているところは、非表示にすることで、見えなくすることも可能です。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;th colspan=&quot;2&quot; rowspan=&quot;2&quot; style=&quot;visibility: hidden;&quot;&gt;&lt;/th&gt;</code></pre></div>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="630" height="271" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-8.png" alt="" class="wp-image-721" style="width:500px" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-8.png 630w, https://iwacode-web.com/wp-content/uploads/2024/02/image-8-300x129.png 300w" sizes="(max-width: 630px) 100vw, 630px" /></figure>



<h3 class="wp-block-heading">注意点</h3>



<p>colspanとrowspanですが、それぞれ複数列、複数行存在するレイアウトでないと、正しく動作しません。</p>



<p>以下の例をご覧ください。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th colspan=&quot;2&quot;&gt;&lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;

    &lt;!-- CSS省略 --&gt;</code></pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="322" height="49" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-5.png" alt="" class="wp-image-715" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-5.png 322w, https://iwacode-web.com/wp-content/uploads/2024/02/image-5-300x46.png 300w" sizes="(max-width: 322px) 100vw, 322px" /></figure>



<p>このようにcolspanを２で指定しても、複数行ないため、正しく動作しません。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th colspan=&quot;2&quot;&gt;&lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;th&gt;&lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;</code></pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="418" height="59" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-6.png" alt="" class="wp-image-717" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-6.png 418w, https://iwacode-web.com/wp-content/uploads/2024/02/image-6-300x42.png 300w" sizes="(max-width: 418px) 100vw, 418px" /></figure>



<p>複数行作成することで、colspanでの指定が有効となります。※rowspanの場合でも同様となります。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>単一行の場合は、tableタグを使用する必要もないですし、要素の幅をCSSで調整するとよいですね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p>どのようなときにtableタグを使用したほうがよいのかについては、以下の記事にて解説しております！</p>



<p>こちらもご参考いただけますと幸いです。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240219-1-300x169.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://iwacode-web.com/tabletag-how-to/" data-wpel-link="internal">tableタグは使わない？どんな時に使う？使用するケースについて解説</a>
						<span class="p-blogCard__excerpt">こんにちは。IWACODEの岩村彰斗です。 今回はtableタグについて、どのようなときに使用するのが良いのか、tableタグを使用しない場合はどのようにするのかについて解説&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h2 class="wp-block-heading">さいごに</h2>



<p>いかがでしたでしょうか。</p>



<p>表の中でExcelのように結合されているようなレイアウトの場合は、colspan、rowspanで実現することが可能です。</p>



<p>個別にCSSで調整することも可能ですが、tableタグの場合はこのような方法もあるということを知っておくだけで、コーディングを行う上での引き出しが増えると思います！</p>



<p>本記事が少しでも参考になりましたら幸いです。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iwacode-web.com/html-tabletag-join/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【初心者向け】tableタグの使い方！tr/th/tdなど基本的を覚えてなレイアウトを作成する</title>
		<link>https://iwacode-web.com/html-tabletag-beginner/</link>
					<comments>https://iwacode-web.com/html-tabletag-beginner/#respond</comments>
		
		<dc:creator><![CDATA[岩村　彰斗]]></dc:creator>
		<pubDate>Tue, 20 Feb 2024 04:32:33 +0000</pubDate>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Web制作]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[コーディング]]></category>
		<category><![CDATA[初心者向け]]></category>
		<guid isPermaLink="false">https://iwacode-web.com/?p=666</guid>

					<description><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240220.jpg" class="webfeedsFeaturedVisual" /></p>こんにちは。IWACODEの岩村彰斗です。 今回はtableタグについて、初心者の方向けに、基本的なコーディング方法について解説いたします。 tableタグで使用されるタグの種類 tableタグの基本的な記載方法について [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/02/blog_20240220.jpg" class="webfeedsFeaturedVisual" /></p>
<p>こんにちは。IWACODEの岩村彰斗です。</p>



<p>今回はtableタグについて、初心者の方向けに、基本的なコーディング方法について解説いたします。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>tableタグって、trとかthとかいろいろ出てきて覚えづらいんですよね･･･</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>tableタグはdivタグやpタグと違って、使用するタグにルールがあるため、少し癖がありますね。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>どのようにして覚えていったらよいでしょうか？</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>タグの名前と文章だけ見ても中々覚えづらいので、実際に手を動かして作りながら覚えていきましょう！<br>今回は以下のようなレイアウトを作っていきます。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<figure class="wp-block-image size-full is-resized"><img decoding="async" width="1000" height="554" src="https://iwacode-web.com/wp-content/uploads/2024/02/20240220-01-1.jpg" alt="" class="wp-image-672" style="width:536px;height:auto" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/20240220-01-1.jpg 1000w, https://iwacode-web.com/wp-content/uploads/2024/02/20240220-01-1-300x166.jpg 300w, https://iwacode-web.com/wp-content/uploads/2024/02/20240220-01-1-768x425.jpg 768w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>


<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>よく見かけるレイアウトですね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>作り方さえ覚えてしまえば、ある程度のレイアウトは応用して作れるようになるので、頑張っていきましょう！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h2 class="wp-block-heading">tableタグで使用されるタグの種類</h2>


<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>まず、tableタグで使用されるタグは以下のようになります。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<div class="wp-block-group is-style-big_icon_memo"><div class="wp-block-group__inner-container">
<ul class="wp-block-list">
<li>&lt;table>・・・&lt;/table></li>



<li>&lt;tr>・・・&lt;/tr></li>



<li>&lt;th>・・・&lt;/th></li>



<li>&lt;td>・・・&lt;/td></li>



<li>&lt;thead>・・・&lt;/thead></li>



<li>&lt;tbody>・・・&lt;/tbody></li>



<li>&lt;tfoot>・・・&lt;/tfoot></li>
</ul>
</div></div>


<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>いや、いきなり７つ出てきたんですけど・・・</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>７つ記載しましたが、頻繁に使用するのは、tr、th、tdです！<br>まず先ほどのレイアウトがどのように構成されているか見てみましょう！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<figure class="wp-block-image size-full"><img decoding="async" width="1000" height="545" src="https://iwacode-web.com/wp-content/uploads/2024/02/20240220-02.jpg" alt="" class="wp-image-675" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/20240220-02.jpg 1000w, https://iwacode-web.com/wp-content/uploads/2024/02/20240220-02-300x164.jpg 300w, https://iwacode-web.com/wp-content/uploads/2024/02/20240220-02-768x419.jpg 768w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>


<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>t<strong>ableタグが一番外側</strong>にあって、<strong>１行ずつtrタグ</strong>が記載されていますね。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h2 class="wp-block-heading">tableタグの基本的な記載方法について</h2>



<h3 class="wp-block-heading">見出し（header）にあたる部分のコーディング</h3>


<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>では、まずこの上の見出しの部分からコードを書いていきますね。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<figure class="wp-block-image size-full is-resized"><img decoding="async" width="1000" height="554" src="https://iwacode-web.com/wp-content/uploads/2024/02/20240220-03-1.jpg" alt="" class="wp-image-677" style="width:500px" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/20240220-03-1.jpg 1000w, https://iwacode-web.com/wp-content/uploads/2024/02/20240220-03-1-300x166.jpg 300w, https://iwacode-web.com/wp-content/uploads/2024/02/20240220-03-1-768x425.jpg 768w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;&lt;/th&gt;
        &lt;th&gt;国語&lt;/th&gt;
        &lt;th&gt;算数&lt;/th&gt;
        &lt;th&gt;理科&lt;/th&gt;
        &lt;th&gt;社会&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
  &lt;/table&gt;

  &lt;style&gt;
    thead {
      background-color: #2CA5FF;
      color: #fff;
    }

    th,
    td {
      border-collapse: collapse;
      border: 3px solid #fff;
      padding: 10px;
      text-align: center;
      width: 100px;
    }
  &lt;/style&gt;</code></pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="476" height="79" src="https://iwacode-web.com/wp-content/uploads/2024/02/image.png" alt="" class="wp-image-678" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image.png 476w, https://iwacode-web.com/wp-content/uploads/2024/02/image-300x50.png 300w" sizes="(max-width: 476px) 100vw, 476px" /></figure>


<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>上の見出し部分だけ作成してみました。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>trタグの中にthタグとtdタグが入るんですね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>tableタグの構成では、大枠をtableタグとして、その中にデザイン上１行ずつコーディングを行っていきます。<br>１行ずつtrタグで囲っていくイメージですね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p class="is-style-big_icon_point">・<strong>trタグ</strong><br><strong>Table Row</strong>の略で、tableタグ内の行を意味します。<span class="swl-marker mark_yellow">子要素としてthタグ、tdタグを使用する</span>ことができます。<br>・<strong>thタグ</strong><br><strong>Table Header</strong>の略で、tableタグ内の見出しとして使用します。<br>・<strong>tdタグ</strong><br><strong>Table Data</strong>の略で、tableタグ内のデータとして使用します。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>theadタグで囲われていますが、これはどのような意味なのでしょうか？</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>theadタグは、HTML上で<strong>どこが見出し部分にあたるのか</strong>わかりやすくするために使用すると認識いただいて大丈夫です。<br>また、<strong>CSSの適用が行いやすくなる</strong>などの利点があります。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>見出しにあたる部分をtheadタグで囲っているので、例えばtheadタグにbackgroundプロパティを指定すれば、一気に背景色が変更できますね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>次は内容部分のコーディングを行っていきます。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h3 class="wp-block-heading">内容（body）にあたる部分のコーディング</h3>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="1000" height="554" src="https://iwacode-web.com/wp-content/uploads/2024/02/20240220-04.jpg" alt="" class="wp-image-679" style="width:500px" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/20240220-04.jpg 1000w, https://iwacode-web.com/wp-content/uploads/2024/02/20240220-04-300x166.jpg 300w, https://iwacode-web.com/wp-content/uploads/2024/02/20240220-04-768x425.jpg 768w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;&lt;/th&gt;
        &lt;th&gt;国語&lt;/th&gt;
        &lt;th&gt;算数&lt;/th&gt;
        &lt;th&gt;理科&lt;/th&gt;
        &lt;th&gt;社会&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;!-- ↓↓↓ HTMLはここから追記 ↓↓↓ --&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;th&gt;A君&lt;/th&gt;
        &lt;td&gt;80&lt;/td&gt;
        &lt;td&gt;85&lt;/td&gt;
        &lt;td&gt;90&lt;/td&gt;
        &lt;td&gt;95&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;th&gt;B君&lt;/th&gt;
        &lt;td&gt;85&lt;/td&gt;
        &lt;td&gt;90&lt;/td&gt;
        &lt;td&gt;95&lt;/td&gt;
        &lt;td&gt;80&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;th&gt;C君&lt;/th&gt;
        &lt;td&gt;90&lt;/td&gt;
        &lt;td&gt;95&lt;/td&gt;
        &lt;td&gt;80&lt;/td&gt;
        &lt;td&gt;85&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
    &lt;!-- ↑↑↑ HTMLはここまで追記 ↑↑↑ --&gt;
  &lt;/table&gt;

  &lt;style&gt;
    thead {
      background-color: #2CA5FF;
      color: #fff;
    }

    th,
    td {
      border-collapse: collapse;
      border: 3px solid #fff;
      padding: 10px;
      text-align: center;
      width: 100px;
    }

    /* ↓↓↓ CSSはここから追記 ↓↓↓ */
    tbody {
      color: #555;
      font-weight: 700;
    }

    tbody th {
      background-color: #2CD9FF;
    }

    tbody td {
      background-color: #FFF8DF;
    }
    /* ↑↑↑ CSSはここから追記 ↑↑↑ */
  &lt;/style&gt;</code></pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="469" height="191" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-1.png" alt="" class="wp-image-682" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-1.png 469w, https://iwacode-web.com/wp-content/uploads/2024/02/image-1-300x122.png 300w" sizes="(max-width: 469px) 100vw, 469px" /></figure>


<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>内容部分を３行分追加しました。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>内容部分はtbodyで囲ってありますね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>tbodyタグも同様に、記載しなくても動作しますが、はやり囲っておいた方が見やすく、丁寧な記載になります。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>thタグとtdタグが使用されていますが、この違いは何ですか？</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p><strong>見出しにあたる部分はthタグ</strong>を使用し、<strong>データ部分にあたるところはtdタグ</strong>を使用しますね！内容部分でも一番左側が見出しになっているので、thタグを使用しています。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>tbodyで囲っているので、tbodyの中のthタグというようにCSSが適用できますね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>theadタグと同様にCSSが適用しやすくなるのも良いところですね。<br>では最後に表のフッター部分を作成していきます。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h3 class="wp-block-heading">フッター（footer）にあたる部分のコーディング</h3>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="1000" height="554" src="https://iwacode-web.com/wp-content/uploads/2024/02/20240220-05.jpg" alt="" class="wp-image-685" style="width:500px" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/20240220-05.jpg 1000w, https://iwacode-web.com/wp-content/uploads/2024/02/20240220-05-300x166.jpg 300w, https://iwacode-web.com/wp-content/uploads/2024/02/20240220-05-768x425.jpg 768w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;&lt;/th&gt;
        &lt;th&gt;国語&lt;/th&gt;
        &lt;th&gt;算数&lt;/th&gt;
        &lt;th&gt;理科&lt;/th&gt;
        &lt;th&gt;社会&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;th&gt;A君&lt;/th&gt;
        &lt;td&gt;80&lt;/td&gt;
        &lt;td&gt;85&lt;/td&gt;
        &lt;td&gt;90&lt;/td&gt;
        &lt;td&gt;95&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;th&gt;B君&lt;/th&gt;
        &lt;td&gt;85&lt;/td&gt;
        &lt;td&gt;90&lt;/td&gt;
        &lt;td&gt;95&lt;/td&gt;
        &lt;td&gt;80&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;th&gt;C君&lt;/th&gt;
        &lt;td&gt;90&lt;/td&gt;
        &lt;td&gt;95&lt;/td&gt;
        &lt;td&gt;80&lt;/td&gt;
        &lt;td&gt;85&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
    &lt;!-- ↓↓↓ HTMLはここから追記 ↓↓↓ --&gt;
    &lt;tfoot&gt;
      &lt;tr&gt;
        &lt;th&gt;平均&lt;/th&gt;
        &lt;td&gt;85&lt;/td&gt;
        &lt;td&gt;90&lt;/td&gt;
        &lt;td&gt;90&lt;/td&gt;
        &lt;td&gt;85&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tfoot&gt;
    &lt;!-- ↑↑↑ HTMLはここまで追記 ↑↑↑ --&gt;
  &lt;/table&gt;

  &lt;style&gt;
    thead {
      background-color: #2CA5FF;
      color: #fff;
    }

    th,
    td {
      border-collapse: collapse;
      border: 3px solid #fff;
      padding: 10px;
      text-align: center;
      width: 100px;
    }

    tbody {
      color: #555;
      font-weight: 700;
    }

    tbody th {
      background-color: #2CD9FF;
    }

    tbody td {
      background-color: #FFF8DF;
    }

    /* ↓↓↓ CSSはここから追記 ↓↓↓ */
    tfoot {
      background-color: #ECECEC;
      color: #555;
      font-weight: 700;
    }
    /* ↑↑↑ CSSはここから追記 ↑↑↑ */
  &lt;/style&gt;</code></pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="464" height="231" src="https://iwacode-web.com/wp-content/uploads/2024/02/image-2.png" alt="" class="wp-image-686" srcset="https://iwacode-web.com/wp-content/uploads/2024/02/image-2.png 464w, https://iwacode-web.com/wp-content/uploads/2024/02/image-2-300x149.png 300w" sizes="(max-width: 464px) 100vw, 464px" /></figure>


<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>フッター部分を追加しました。これで完成ですね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left -sp-vrtcl" data-col="green"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/Group-42-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>フッター部分はtfootタグを使用するんですね！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-balloon"><div class="c-balloon -bln-right -sp-vrtcl" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://iwacode-web.com/wp-content/uploads/2024/02/24821276-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">筆者</span></div><div class="c-balloon__body -speaking -border-none"><div class="c-balloon__text">
<p>theadタグ、tbodyタグと同様にフッター部分にあたる箇所をtfootタグで囲っております。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h2 class="wp-block-heading">さいごに</h2>



<p>今回は基本的なtableタグの記載方法について解説させていただきました。</p>



<p>theadタグ、tbodyタグ、tfootタグについてはなくても問題はないのですが、メンテナンスの観点から考えると、囲っておいた方が構成が分かりやすく、管理もしやすくなるため、記載したほうが良いと考えております。</p>



<p>今回ご紹介した以外にも、Excelのようにセルが結合されているような表も実装することができ、こちらは別途解説させていただく予定です。</p>



<p>複雑そうに見えて、実際のところ、trタグの中にthタグ、tdタグを繰り返し記載していくことが多いので、実際にコーディングをしながら慣れていきたいですね！</p>



<p>今回の記事が参考になりましたら幸いです。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iwacode-web.com/html-tabletag-beginner/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>HTML レスポンシブデザインでの画像の切り替え方法</title>
		<link>https://iwacode-web.com/html-picture-tag/</link>
					<comments>https://iwacode-web.com/html-picture-tag/#respond</comments>
		
		<dc:creator><![CDATA[岩村　彰斗]]></dc:creator>
		<pubDate>Thu, 04 Jan 2024 13:21:13 +0000</pubDate>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Web制作]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[コーディング]]></category>
		<guid isPermaLink="false">https://iwacode-web.com/?p=476</guid>

					<description><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/01/blog_20240104.jpg" class="webfeedsFeaturedVisual" /></p>Webサイト制作を行っていると、パソコンとスマートフォンで表示させたい画像が異なる場合があります。 パソコンは基本横向きでの表示となりますが、スマートフォンやタブレットは縦で見ることが多く、どうしても同じ画像を表示すると [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2024/01/blog_20240104.jpg" class="webfeedsFeaturedVisual" /></p>
<p>Webサイト制作を行っていると、パソコンとスマートフォンで表示させたい画像が異なる場合があります。</p>



<p>パソコンは基本横向きでの表示となりますが、スマートフォンやタブレットは縦で見ることが多く、どうしても同じ画像を表示すると見栄えが悪くなってしまうことがあります。</p>



<p>例えば横長の画像をスマートフォンで見た場合、縮小されてしまいかなり小さくなってしまうなど・・・</p>



<p>パソコンでは16：9などの横長で表示し、スマートフォンでは1：1などの正方形サイズで表示するなど、さまざまです。</p>



<p>みなさまはWeb制作を行う際に、パソコンとスマートフォン（タブレット）で画像を切り替える場合はどのようにされていますか？</p>



<p>CSSのメディアクエリで実装されているという方、HTMLの<span class="swl-marker mark_yellow">pictureタグ</span>を使用することで簡単に実装することが可能です。</p>



<p>CSSを記載せず、<span class="swl-marker mark_yellow">HTMLだけで完結</span>することができるため、<span class="swl-marker mark_yellow">コードの量の減らす</span>ことができます。</p>



<p>画像の切り替えはpictureタグで行うようにしましょう！</p>



<h2 class="wp-block-heading">pictureタグの基本的な書き方</h2>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;picture&gt;
  &lt;source srcset=&quot;画像ファイルのパス&quot; media=&quot;(min-width: 1024px)&quot;&gt;
  &lt;source srcset=&quot;画像ファイルのパス&quot; media=&quot;(min-width: 768px)&quot;&gt;
  &lt;img src=&quot;画像のパス&quot; alt=”代替テキスト”&gt;
&lt;/picture&gt;</code></pre></div>



<p>pictureタグの中に、<span class="swl-marker mark_yellow">sourceタグ、imgタグ</span>を記載します。</p>



<p>sourceタグにはsrcset属性、media属性を指定することができ、</p>



<p><span class="swl-marker mark_yellow">srcset属性は、画像ファイルのパスを指定</span>、</p>



<p><span class="swl-marker mark_yellow">media属性はmin-widthやmax-widthを使用</span>して、画面の幅を指定します。</p>



<h3 class="wp-block-heading">sourceタグの属性について</h3>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;picture&gt;
  &lt;source srcset=&quot;画像ファイルのパス&quot; media=&quot;(min-width: 1024px)&quot;&gt;　&lt;!-- 優先1--&gt;
  &lt;source srcset=&quot;画像ファイルのパス&quot; media=&quot;(min-width: 768px)&quot;&gt; 　&lt;!-- 優先2--&gt;
  &lt;img src=&quot;画像ファイルのパス&quot; alt=&quot;&quot;&gt;
&lt;/picture&gt;</code></pre></div>



<p>source属性は複数設定することができ、<span class="swl-marker mark_yellow">上から順に優先順位が高く</span>なり、<span class="swl-marker mark_yellow">条件に当てはまった</span>画像ファイルが出力される仕様となります。</p>



<p>source属性で指定している条件にあてはまらなかった場合はimgタグで指定している画像ファイルが出力されます。</p>



<p>上記の場合、</p>



<p>画面幅が1024px以上の場合は「優先1」の画像ファイルが出力、</p>



<p>画面幅が1023px～768pxの場合は「優先2」の画像ファイルが出力、</p>



<p>それ以外（以下）の場合は、imgタグで指定されている画像ファイルが出力されます。</p>



<h3 class="wp-block-heading">画像の大きさなど、CSSの指定方法について</h3>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>  &lt;picture class=&quot;image&quot;&gt;
    &lt;source srcset=&quot;./image/PC.jpg&quot; media=&quot;(min-width: 1024px)&quot;&gt;
    &lt;img src=&quot;./image/sm.jpg&quot; alt=&quot;デバイスの画像&quot;&gt;
  &lt;/picture&gt;</code></pre></div>



<div class="hcb_wrap"><pre class="prism line-numbers lang-css" data-lang="CSS"><code>.image img {
　width: 300px;
  height: 300px;
}</code></pre></div>



<p>sourceタグに記載されているタグは、<span class="swl-marker mark_yellow">内部的にimgタグとして置き換えられる</span>ため、<span class="swl-marker mark_yellow">imgタグに対してCSSを記載</span>します。</p>


<div class="wp-block-image">
<figure class="alignleft size-full is-resized"><img decoding="async" width="1000" height="591" src="https://iwacode-web.com/wp-content/uploads/2024/01/01-1.jpg" alt="" class="wp-image-487" style="width:500px" srcset="https://iwacode-web.com/wp-content/uploads/2024/01/01-1.jpg 1000w, https://iwacode-web.com/wp-content/uploads/2024/01/01-1-300x177.jpg 300w, https://iwacode-web.com/wp-content/uploads/2024/01/01-1-768x454.jpg 768w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>
</div>


<p>min-width: 1024pxをmedia属性に指定しているため、1024pxではpc.jpgが表示されております。</p>


<div class="wp-block-image">
<figure class="alignleft size-full is-resized"><img decoding="async" width="1000" height="591" src="https://iwacode-web.com/wp-content/uploads/2024/01/02-1.jpg" alt="" class="wp-image-488" style="width:500px" srcset="https://iwacode-web.com/wp-content/uploads/2024/01/02-1.jpg 1000w, https://iwacode-web.com/wp-content/uploads/2024/01/02-1-300x177.jpg 300w, https://iwacode-web.com/wp-content/uploads/2024/01/02-1-768x454.jpg 768w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>
</div>


<p>画面の幅が1023pxになったため、画像がsm.jpgに切り替わりました。</p>



<h2 class="wp-block-heading">さいごに</h2>



<p>pictureタグの使用方法について解説させていただきました。</p>



<p>CSSでメディアクエリを使用して実現することも可能ですが、pictureタグを使用することによりコーディングの量を減らすことができます。</p>



<p>pictureタグで実装する場合はHTMLだけで切り替えを実装できるため、レスポンシブ対応も容易にできます。</p>



<p>Webサイトで使用する画像を、デバイスごとに切り替えたい場合は、ぜひpictureタグを使用してみてください。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iwacode-web.com/html-picture-tag/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CSSのマージン（margin）とパディング（padding）の違いがわからない！図を用いて簡単に説明！</title>
		<link>https://iwacode-web.com/css-margin-padding/</link>
					<comments>https://iwacode-web.com/css-margin-padding/#respond</comments>
		
		<dc:creator><![CDATA[岩村　彰斗]]></dc:creator>
		<pubDate>Thu, 14 Dec 2023 13:40:23 +0000</pubDate>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Web制作]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[コーディング]]></category>
		<category><![CDATA[初心者向け]]></category>
		<guid isPermaLink="false">https://iwacode-web.com/?p=226</guid>

					<description><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2023/12/blog_20231214-1024x576.jpg" class="webfeedsFeaturedVisual" /></p>CSSで頻繁に使用するマージン（margin）とパディング（padding）ですが、似たような指定のため、ごちゃごちゃになってしまう方もいらっしゃるかと思います。 今回はこのマージン（margin）とパディング（padd [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://iwacode-web.com/wp-content/uploads/2023/12/blog_20231214-1024x576.jpg" class="webfeedsFeaturedVisual" /></p>
<p>CSSで頻繁に使用するマージン（margin）とパディング（padding）ですが、似たような指定のため、ごちゃごちゃになってしまう方もいらっしゃるかと思います。</p>



<p>今回はこのマージン（margin）とパディング（padding）について詳しく、かつ簡単に解説させていただきます！</p>



<p>本記事を読むことによって、マージンとパディングについてしっかり理解して、実際のコーディングでも使用できるようになると思います！</p>



<p>実際の記載方法にも触れていきますので、ぜひ最後まで読んでいただけると幸いです！</p>



<h2 class="wp-block-heading">マージン（margin）とは？</h2>



<p>CSSでは<strong><span class="swl-marker mark_yellow">余白</span></strong>を表す意味合いで使用されており、主にHTMLの<span class="swl-marker mark_yellow"><strong>要素と要素の間隔を調整するため</strong></span>に使用します。</p>



<p>まずは下記の例をご覧ください。</p>



<pre class="wp-block-code"><code>&lt;!-- HTML --&gt;
&lt;div class="box-1"&gt;box-1&lt;/div&gt;

/* CSS */
.box-1 {
  width: 200px;
  height: 200px;
  background-color: pink;
}
</code></pre>


<div class="wp-block-image">
<figure class="alignleft size-full is-resized"><img decoding="async" width="400" height="399" src="https://iwacode-web.com/wp-content/uploads/2023/12/01-3.jpg" alt="" class="wp-image-230" style="width:250px" srcset="https://iwacode-web.com/wp-content/uploads/2023/12/01-3.jpg 400w, https://iwacode-web.com/wp-content/uploads/2023/12/01-3-300x300.jpg 300w, https://iwacode-web.com/wp-content/uploads/2023/12/01-3-150x150.jpg 150w" sizes="(max-width: 400px) 100vw, 400px" /></figure>
</div>


<p>このようにボックスが表示されます。</p>



<p>もう一つ別の名前で追加してみましょう。</p>



<pre class="wp-block-code"><code>&lt;!-- HTML --&gt;
&lt;div class="box-1"&gt;box-1&lt;/div&gt;
&lt;div class="box-2"&gt;box-2&lt;/div&gt;

/* CSS */
.box-1 {
  width: 200px;
  height: 200px;
  background-color: pink;
}
.box-2 {
  width: 200px;
  height: 200px;
  background-color: orange;
}</code></pre>


<div class="wp-block-image">
<figure class="alignleft size-full is-resized"><img decoding="async" width="400" height="799" src="https://iwacode-web.com/wp-content/uploads/2023/12/02-1.jpg" alt="" class="wp-image-231" style="width:250px" srcset="https://iwacode-web.com/wp-content/uploads/2023/12/02-1.jpg 400w, https://iwacode-web.com/wp-content/uploads/2023/12/02-1-150x300.jpg 150w" sizes="(max-width: 400px) 100vw, 400px" /></figure>
</div>


<p>特に指定をしていないため、くっついて表示されています。</p>



<p>ここにマージンを指定してみます。</p>



<pre class="wp-block-code"><code>/* CSS */
.box-1 {
  width: 200px;
  height: 200px;
  background-color: pink;
  <span class="swl-marker mark_yellow">margin-bottom: 30px;    /* 追加 */
</span>
}
.box-2 {
  width: 200px;
  height: 200px;
  background-color: orange;
}</code></pre>


<div class="wp-block-image">
<figure class="alignleft size-full is-resized"><img decoding="async" width="405" height="859" src="https://iwacode-web.com/wp-content/uploads/2023/12/03-1.jpg" alt="" class="wp-image-232" style="width:249px" srcset="https://iwacode-web.com/wp-content/uploads/2023/12/03-1.jpg 405w, https://iwacode-web.com/wp-content/uploads/2023/12/03-1-141x300.jpg 141w" sizes="(max-width: 405px) 100vw, 405px" /></figure>
</div>


<p>「box-1」のclassが付与されている要素の下に「margin-bottom: 30px」を指定しました。マージンでは<span class="swl-marker mark_yellow">要素の外側</span>、いわゆる<span class="swl-marker mark_yellow">余白にあたる部分</span>の幅を指定するプロパティとなります。</p>



<p>marginプロパティでは、上下左右に指定することが可能です。</p>



<pre class="wp-block-code"><code>margin-top: 40px;     /* 要素の上側に40pxの余白 */
margin-right: 30px;   /* 要素の右側に30pxの余白 */
margin-bottom: 20px;  /* 要素の下側に20pxの余白 */
margin-left: 10px;    /* 要素の左側に10pxの余白 */
</code></pre>



<p>上下左右を一気に指定することも可能で、実際には下記の指定方法をよく使用します。</p>



<pre class="wp-block-code"><code>margin: 40px 30px 20px 10px;  /* 上側 右側 下側 左側　*/</code></pre>



<p>上側から始まり、<span class="swl-marker mark_yellow">時計回り</span>に値を指定します。<br>このパターンでは、4方向すべて違う値でしたが、実際にはさまざまなパタンがあり、指定方法も異なります。<br>下記がその他の例となります。</p>



<pre class="wp-block-code"><code>/* 4方向すべて同じ場合の省略形 */
margin: 40px;

/* 上下は40px、左右は20pxの省略形 */
margin: 40px 20px;

/* 上下は40px、左右は30px、下は20pxの省略形 */
margin: 40px 30px 20px;  </code></pre>



<h2 class="wp-block-heading">パディング（padding）とは？</h2>



<p>マージンは外側の余白という意味でした。パディングは反対で、<strong><span class="swl-marker mark_yellow">要素の内側の余白</span></strong>になります！</p>



<p>先ほど使用した図でパティングを使用してみましょう。</p>



<pre class="wp-block-code"><code>/* CSS */
.box-1 {
  width: 200px;
  height: 200px;
  background-color: pink;
  margin-bottom: 30px;
  <span class="swl-marker mark_yellow">padding-top: 20px   /* 追加 */</span>
}
.box-2 {
  width: 200px;
  height: 200px;
  background-color: orange;
}</code></pre>


<div class="wp-block-image">
<figure class="alignleft size-full is-resized"><img decoding="async" width="399" height="860" src="https://iwacode-web.com/wp-content/uploads/2023/12/04.jpg" alt="" class="wp-image-233" style="width:250px" srcset="https://iwacode-web.com/wp-content/uploads/2023/12/04.jpg 399w, https://iwacode-web.com/wp-content/uploads/2023/12/04-139x300.jpg 139w" sizes="(max-width: 399px) 100vw, 399px" /></figure>
</div>


<p>ピンクの中に余白ができているのがわかるかと思います。「padding-top: 20px」を指定することによって、要素の内側の上側に余白が作成されています。</p>



<pre class="wp-block-code"><code>/* CSS */
.box-1 {
  width: 200px;
  height: 200px;
  background-color: pink;
  margin-bottom: 30px;
  padding-top: 20px   /* 追加 */
  <span class="swl-marker mark_yellow">padding-left: 20px;   /* 追加 */</span>
}
.box-2 {
  width: 200px;
  height: 200px;
  background-color: orange;
}</code></pre>



<p>今度は左側にもパティングを追加してみました。</p>


<div class="wp-block-image">
<figure class="alignleft size-full is-resized"><img decoding="async" width="397" height="855" src="https://iwacode-web.com/wp-content/uploads/2023/12/05.jpg" alt="" class="wp-image-234" style="width:250px" srcset="https://iwacode-web.com/wp-content/uploads/2023/12/05.jpg 397w, https://iwacode-web.com/wp-content/uploads/2023/12/05-139x300.jpg 139w" sizes="(max-width: 397px) 100vw, 397px" /></figure>
</div>


<p>要素の中の左側にも余白が作成されました。</p>



<p>パディングもマージンと同様に省略形での記載が可能です。</p>



<pre class="wp-block-code"><code>pading-top: 40px;     /* 要素内の上側に40pxの余白 */
pading-right: 30px;   /* 要素内の右側に30pxの余白 */
pading-bottom: 20px;  /* 要素内の下側に20pxの余白 */
pading-left: 10px;    /* 要素内の左側に10pxの余白 */

/* 上側 右側 下側 左側　*/
pading: 40px 30px 20px 10px;</code></pre>



<pre class="wp-block-code"><code>/* 4方向すべて同じ場合の省略形 */
pading: 40px;

/* 上下は40px、左右は20pxの省略形 */
pading: 40px 20px;

/* 上下は40px、左右は30px、下は20pxの省略形 */
pading: 40px 30px 20px;</code></pre>



<h2 class="wp-block-heading">省略形で記載したほうがよい？</h2>



<p>結論から言って、省略形で記載しなくても、動きに変化があるわけではないので、必須ではありません！</p>



<p>ですが、コーディングの量が多くなってくると、省略できるところを省略していかないと、ものすごく長いコードになってしまい、見辛くなってしまうんですね・・・</p>



<p>省略形を使用しないと、どこまでもスクロールするなんてことに・・・</p>



<p>コーディングにおいては、<span class="swl-marker mark_yellow">1画面でどれだけコードが見れるか</span>、というところが非常に大事になってきます。</p>



<h2 class="wp-block-heading">さいごに</h2>



<p>マージンとパディングについて、解説させていただきました。</p>



<p>ごちゃごちゃになりやすいですが、どちらも実際のコーディングではなくてはならない存在で、非常に大事な部分になります。</p>



<p>実際に使用しながら、理解を深めていけば大丈夫です。</p>



<p>本記事にて少しでもお悩みの解決に繋がれば幸いです！</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iwacode-web.com/css-margin-padding/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
