Want to share your CSS expertise with others? Apply to the MDN Fellowship by April 1! http://mzl.la/MDNFellowship

mozilla

Revision 562329 of border-top-style

  • Revision slug: Web/CSS/border-top-style
  • Revision title: border-top-style
  • Revision id: 562329
  • Created:
  • Creator: J-Mackerel
  • Is current revision? No
  • Comment Added live sample, fixed Values table, requested review

Revision Content

{{ CSSRef("CSS Borders") }}

Summary

The border-top-style CSS property sets the line style of the top border of a box.

Note: The specification doesn't define how borders of different styles connect in the corners.

{{cssbox("border-top-style")}}

Syntax

Formal syntax: {{csssyntax("border-top-style")}}
border-top-style: none
border-top-style: hidden
border-top-style: dotted
border-top-style: dashed
border-top-style: solid
border-top-style: double
border-top-style: groove
border-top-style: ridge
border-top-style: inset
border-top-style: outset

border-top-style: inherit

Values

<br-style>
Is a keyword describing the style of the top border. It can have the following values:
none
 
Like for the hidden keyword, displays no border. In that case, except if a background image is set, the calculated values of {{ cssxref("border-top-width") }} will be 0, even if specified otherwise through the property. In case of table cell and border collapsing, the none value has the lowest priority: it means that if any other conflicting border is set, it will be displayed.
hidden
 
Like for the none keyword, displays no border. In that case, except if a background image is set, the calculated values of {{ cssxref("border-top-width") }} will be 0, even if specified otherwise through the property. In case of table cell and border collapsing, the hidden value has the highest priority: it means that if any other conflicting border is set, it won't be displayed.
dotted
 
Displays a series of rounded dots. The spacing of the dots are not defined by the specification and are implementation-specific. The radius of the dots is half the calculated {{ cssxref("border-top-width") }}.
dashed
 
Displays a series of short square-ended dashes or line segments. The exact size and length of the segments are not defined by the specification and are implementation-specific.
solid
 
Displays a single, straight, solid line.
double
 
Displays two straight lines that add up to the pixel amount defined as {{ cssxref("border-width") }} or {{ cssxref("border-top-width") }}.
groove
 
Displays a border leading to a carved effect. It is the opposite of ridge.
ridge
 
Displays a border with a 3D effect, like if it is coming out of the page. It is the opposite of groove.
inset
 
Displays a border that makes the box appear embedded. It is the opposite of outset. When applied to a table cell with {{ cssxref("border-collapse") }} set to collapsed, this value behaves like groove.
outset
 

Displays a border that makes the box appear in 3D, embossed. It is the opposite of inset. When applied to a table cell with {{ cssxref("border-collapse") }} set to collapsed, this value behaves like ridge.

inherit
Represents the border style used by the parent of the current element.

Examples

HTML Content

<table>
    <tr>
        <td class="b1">none</td>
        <td class="b2">hidden</td>
        <td class="b3">dotted</td>
        <td class="b4">dashed</td>
    </tr>
    <tr>
        <td class="b5">solid</td>
        <td class="b6">double</td>
        <td class="b7">groove</td>
        <td class="b8">ridge</td>
    </tr>
    <tr>
        <td class="b9">inset</td>
        <td class="b10">outset</td>
    </tr>
</table>

CSS Content

/* Define look of the table */
table {
    border-width: 2px;
    background-color: #52E385;
}
tr, td {
    padding: 3px;
}

/* border-top-style example classes */
.b1 {border-top-style:none;}
.b2 {border-top-style:hidden;}
.b3 {border-top-style:dotted;}
.b4 {border-top-style:dashed;}
.b5 {border-top-style:solid;}
.b6 {border-top-style:double;}
.b7 {border-top-style:groove;}
.b8 {border-top-style:ridge;}
.b9 {border-top-style:inset;}
.b10 {border-top-style:outset;}

Output

{{ EmbedLiveSample('Examples', 300, 200) }}

Specifications

Specification Status Comment
{{ SpecName('CSS3 Backgrounds', '#the-border-style', 'border-top-style') }} {{ Spec2('CSS3 Backgrounds') }} No significant change.
{{ SpecName('CSS2.1', 'box.html#border-style-properties', 'border-top-style') }} {{ Spec2('CSS2.1') }} Initial definition.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 5.5 9.2 1.0
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

  • The other style-related border properties: {{ Cssxref("border-left-style") }}, {{ Cssxref("border-right-style") }}, {{ Cssxref("border-bottom-style") }}, and {{ Cssxref("border-style") }}.
  • The other top-border-related properties: {{ Cssxref("border-top") }}, {{ Cssxref("border-top-color") }}, and {{ Cssxref("border-top-width") }}.

Revision Source

<p>{{ CSSRef("CSS Borders") }}</p>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code>border-top-style</code> <a href="/en/CSS" title="CSS">CSS</a> property sets the line style of the top border of a box.</p>
<div class="note">
 <strong>Note:</strong>&nbsp;The specification doesn't define how borders of different styles connect in the corners.</div>
<p>{{cssbox("border-top-style")}}</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="/en-US/docs/CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("border-top-style")}}
</pre>
<pre>
border-top-style: none
border-top-style: hidden
border-top-style: dotted
border-top-style: dashed
border-top-style: solid
border-top-style: double
border-top-style: groove
border-top-style: ridge
border-top-style: inset
border-top-style: outset
<em>
</em>border-top-style: inherit
</pre>
<h3 id="Values">Values</h3>
<dl>
 <dt>
  <code>&lt;br-style&gt;</code></dt>
 <dd>
  Is a keyword describing the style of the top border. It can have the following values:
  <table class="standard-table">
   <tbody>
    <tr>
     <td style="vertical-align:middle;"><code>none</code></td>
     <td style="vertical-align:middle;">
      <div style="margin:0.5em; width:3em; height:3em; border-top-style:none; background-color:palegreen;">
       &nbsp;</div>
     </td>
     <td style="vertical-align:middle;">Like for the <code>hidden</code> keyword, displays no border. In that case, except if a background image is set, the calculated values of {{ cssxref("border-top-width") }} will be <code>0</code>, even if specified otherwise through the property. In case of table cell and border collapsing, the <code>none</code> value has the lowest priority: it means that if any other conflicting border is set, it will be displayed.</td>
    </tr>
    <tr>
     <td style="vertical-align:middle;"><code>hidden</code></td>
     <td style="vertical-align:middle;">
      <div style="margin:0.5em; width:3em; height:3em; border-width:3px; border-top-style:hidden; background-color:palegreen;">
       &nbsp;</div>
     </td>
     <td style="vertical-align:middle;">Like for the <code>none</code> keyword, displays no border. In that case, except if a background image is set, the calculated values of {{ cssxref("border-top-width") }} will be <code>0</code>, even if specified otherwise through the property. In case of table cell and border collapsing, the <code>hidden</code> value has the highest priority: it means that if any other conflicting border is set, it won't be displayed.</td>
    </tr>
    <tr>
     <td style="vertical-align:middle;"><code>dotted</code></td>
     <td style="vertical-align:middle;">
      <div style="margin:0.5em; width:3em; height:3em; border-width:3px; border-top-style:dotted; background-color:palegreen;">
       &nbsp;</div>
     </td>
     <td style="vertical-align:middle;">Displays a series of rounded dots. The spacing of the dots are not defined by the specification and are implementation-specific. The radius of the dots is half the calculated {{ cssxref("border-top-width") }}.</td>
    </tr>
    <tr>
     <td style="vertical-align:middle;"><code>dashed</code></td>
     <td style="vertical-align:middle;">
      <div style="margin:0.5em; width:3em; height:3em; border-width:3px; border-top-style:dashed; background-color:palegreen;">
       &nbsp;</div>
     </td>
     <td style="vertical-align:middle;">Displays a series of short square-ended dashes or line segments. The exact size and length of the segments are not defined by the specification and are implementation-specific.</td>
    </tr>
    <tr>
     <td style="vertical-align:middle;"><code>solid</code></td>
     <td style="vertical-align:middle;">
      <div style="margin:0.5em; width:3em; height:3em; border-width:3px; border-top-style:solid; background-color:palegreen;">
       &nbsp;</div>
     </td>
     <td style="vertical-align:middle;">Displays a single, straight, solid line.</td>
    </tr>
    <tr>
     <td style="vertical-align:middle;"><code>double</code></td>
     <td style="vertical-align:middle;">
      <div style="margin:0.5em; width:3em; height:3em; border-width:3px; border-top-style:double; background-color:palegreen;">
       &nbsp;</div>
     </td>
     <td style="vertical-align:middle;">Displays two straight lines that add up to the pixel amount defined as {{ cssxref("border-width") }} or {{ cssxref("border-top-width") }}.</td>
    </tr>
    <tr>
     <td style="vertical-align:middle;"><code>groove</code></td>
     <td style="vertical-align:middle;">
      <div style="margin:0.5em; width:3em; height:3em; border-width:3px; border-top-style:groove; background-color:palegreen;">
       &nbsp;</div>
     </td>
     <td style="vertical-align:middle;">Displays a border leading to a carved effect. It is the opposite of <code>ridge</code>.</td>
    </tr>
    <tr>
     <td style="vertical-align:middle;"><code>ridge</code></td>
     <td style="vertical-align:middle;">
      <div style="margin:0.5em; width:3em; height:3em; border-width:3px; border-top-style:ridge; background-color:palegreen;">
       &nbsp;</div>
     </td>
     <td style="vertical-align:middle;">Displays a border with a 3D effect, like if it is coming out of the page. It is the opposite of <code>groove</code>.</td>
    </tr>
    <tr>
     <td style="vertical-align:middle;"><code>inset</code></td>
     <td style="vertical-align:middle;">
      <div style="margin:0.5em; width:3em; height:3em; border-width:3px; border-top-style:inset; background-color:palegreen;">
       &nbsp;</div>
     </td>
     <td style="vertical-align:middle;">Displays a border that makes the box appear embedded. It is the opposite of <code>outset</code>. When applied to a table cell with {{ cssxref("border-collapse") }} set to <code>collapsed</code>, this value behaves like <code>groove</code>.</td>
    </tr>
    <tr>
     <td style="vertical-align:middle;"><code>outset</code></td>
     <td style="vertical-align:middle;">
      <div style="margin:0.5em; width:3em; height:3em; border-width:3px; border-top-style:outset; background-color:palegreen;">
       &nbsp;</div>
     </td>
     <td style="vertical-align:middle;">
      <p>Displays a border that makes the box appear in 3D, embossed. It is the opposite of <code>inset</code>. When applied to a table cell with {{ cssxref("border-collapse") }} set to <code>collapsed</code>, this value behaves like <code>ridge</code>.</p>
     </td>
    </tr>
   </tbody>
  </table>
 </dd>
 <dt>
  <code>inherit</code></dt>
 <dd>
  Represents the border style used by the parent of the current element.</dd>
</dl>
<h2 name="Examples">Examples</h2>
<h4>HTML Content</h4>
<pre class="brush: html">
&lt;table&gt;
&nbsp;&nbsp;&nbsp; &lt;tr&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td class="b1"&gt;none&lt;/td&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td class="b2"&gt;hidden&lt;/td&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td class="b3"&gt;dotted&lt;/td&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td class="b4"&gt;dashed&lt;/td&gt;
&nbsp;&nbsp;&nbsp; &lt;/tr&gt;
&nbsp;&nbsp;&nbsp; &lt;tr&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td class="b5"&gt;solid&lt;/td&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td class="b6"&gt;double&lt;/td&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td class="b7"&gt;groove&lt;/td&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td class="b8"&gt;ridge&lt;/td&gt;
&nbsp;&nbsp;&nbsp; &lt;/tr&gt;
&nbsp;&nbsp;&nbsp; &lt;tr&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td class="b9"&gt;inset&lt;/td&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td class="b10"&gt;outset&lt;/td&gt;
&nbsp;&nbsp;&nbsp; &lt;/tr&gt;
&lt;/table&gt;</pre>
<h4>CSS Content</h4>
<pre class="brush: css">
/* Define look of the table */
table {
&nbsp;&nbsp;&nbsp; border-width: 2px;
&nbsp;&nbsp;&nbsp; background-color: #52E385;
}
tr, td {
&nbsp;&nbsp;&nbsp; padding: 3px;
}

/* border-top-style example classes */
.b1 {border-top-style:none;}
.b2 {border-top-style:hidden;}
.b3 {border-top-style:dotted;}
.b4 {border-top-style:dashed;}
.b5 {border-top-style:solid;}
.b6 {border-top-style:double;}
.b7 {border-top-style:groove;}
.b8 {border-top-style:ridge;}
.b9 {border-top-style:inset;}
.b10 {border-top-style:outset;}</pre>
<h4>Output</h4>
<p>{{ EmbedLiveSample('Examples', 300, 200) }}</p>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('CSS3 Backgrounds', '#the-border-style', 'border-top-style') }}</td>
   <td>{{ Spec2('CSS3 Backgrounds') }}</td>
   <td>No significant change.</td>
  </tr>
  <tr>
   <td>{{ SpecName('CSS2.1', 'box.html#border-style-properties', 'border-top-style') }}</td>
   <td>{{ Spec2('CSS2.1') }}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_Compatibility" name="Browser_Compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>1.0</td>
    <td>1.0</td>
    <td>5.5</td>
    <td>9.2</td>
    <td>1.0</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE&nbsp;Phone</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<h2 id="See_Also" name="See_Also">See also</h2>
<ul>
 <li>The other style-related border properties: {{ Cssxref("border-left-style") }}, {{ Cssxref("border-right-style") }}, {{ Cssxref("border-bottom-style") }}, and {{ Cssxref("border-style") }}.</li>
 <li>The other top-border-related properties: {{ Cssxref("border-top") }}, {{ Cssxref("border-top-color") }}, and {{ Cssxref("border-top-width") }}.</li>
</ul>
Revert to this revision