--- title: border-top-width slug: Web/CSS/border-top-width tags: - CSS - CSS プロパティ - CSS 背景と境界 - Reference - border - border-top - border-width translation_of: Web/CSS/border-top-width --- <div>{{CSSRef}}</div> <p><a href="/ja/docs/Web/CSS">CSS</a> の <strong><code>border-top-width</code></strong> プロパティは、要素の上側の境界の幅を設定します。</p> <div>{{EmbedInteractiveExample("pages/css/border-top-width.html")}}</div> <p class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力したい場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</p> <h2 id="Syntax" name="Syntax">構文</h2> <pre class="brush:css no-line-numbers">/* キーワード値 */ border-top-width: thin; border-top-width: medium; border-top-width: thick; /* <length> 値 */ border-top-width: 10em; border-top-width: 3vmax; border-top-width: 6px; /* グローバルキーワード */ border-top-width: inherit; border-top-width: initial; border-top-width: unset; </pre> <h3 id="Values" name="Values">値</h3> <dl> <dt><code><line-width></code></dt> <dd>明示的な非負の {{cssxref("<length>")}} またはキーワードで、境界の幅を定義します。キーワードの場合、以下の値のうちの一つでなければなりません。 <table class="standard-table"> <tbody> <tr> <td><code>thin</code></td> <td> <div style="margin: 0.5em; width: 3em; height: 3em; border-top-style: solid; border-top-width: thin; background-color: palegreen;"> </div> </td> <td>細い境界線</td> </tr> <tr> <td><code>medium</code></td> <td> <div style="margin: 0.5em; width: 3em; height: 3em; border-top-style: solid; border-top-width: medium; background-color: palegreen;"> </div> </td> <td>中くらいの境界線</td> </tr> <tr> <td><code>thick</code></td> <td> <div style="margin: 0.5em; width: 3em; height: 3em; border-top-style: solid; border-top-width: thick; background-color: palegreen;"> </div> </td> <td>太い境界線</td> </tr> </tbody> </table> <div class="note"> <p><strong>メモ:</strong> 仕様書ではそれぞれのキーワードで示される正確な太さを定義していないため、何れか一つを使用した場合の詳細な結果は、実装に依存します。とは言っても、常に <code>thin ≤ medium ≤ thick</code> というパターンに従い、値は同じ文書の中では一貫しています。</p> </div> </dd> </dl> <h3 id="Formal_syntax" name="Formal_syntax">形式文法</h3> {{csssyntax}} <h2 id="Example" name="Example">例</h2> <h3 id="HTML">HTML</h3> <pre class="brush: html"><div>Element 1</div> <div>Element 2</div></pre> <h3 id="CSS">CSS</h3> <pre class="brush: css">div { border: 1px solid red; margin: 1em 0; } div:nth-child(1) { border-top-width: thick; } div:nth-child(2) { border-top-width: 2em; }</pre> <h3 id="Result" name="Result">結果</h3> <p>{{EmbedLiveSample('Example', '100%')}}</p> <h2 id="Specifications" name="Specifications">仕様書</h2> <table class="standard-table"> <thead> <tr> <th scope="col">仕様書</th> <th scope="col">状態</th> <th scope="col">備考</th> </tr> </thead> <tbody> <tr> <td>{{SpecName('CSS3 Backgrounds', '#the-border-width', 'border-top-width')}}</td> <td>{{Spec2('CSS3 Backgrounds')}}</td> <td>目立った変更はなし。</td> </tr> <tr> <td>{{SpecName('CSS2.1', 'box.html#border-width-properties', 'border-top-width')}}</td> <td>{{Spec2('CSS2.1')}}</td> <td>目立った変更はなし。</td> </tr> <tr> <td>{{SpecName('CSS1', '#border-left-width', 'border-top-width')}}</td> <td>{{Spec2('CSS1')}}</td> <td>初回定義</td> </tr> </tbody> </table> <p>{{cssinfo}}</p> <h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2> <p>{{Compat("css.properties.border-top-width")}}</p> <h2 id="See_also" name="See_also">関連情報</h2> <ul> <li>他の border-width 関連 CSS プロパティ: {{Cssxref("border-left-width")}}, {{Cssxref("border-right-width")}}, {{Cssxref("border-bottom-width")}}, {{Cssxref("border-width")}}</li> <li>他の border-top 関連 CSS プロパティ: {{Cssxref("border")}}, {{Cssxref("border-top")}}, {{Cssxref("border-top-style")}}, {{Cssxref("border-top-color")}}</li> </ul>