border-style

  • Revision slug: CSS/border-style
  • Revision title: border-style
  • Revision id: 289908
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

Summary

The border-style CSS property is a shorthand property for setting the line style for all four sides of the elements border.

Note: The default value of border-style is none. This means that if you change the {{ Cssxref("border-width") }} and the {{ Cssxref("border-color") }}, you will not see the border unless you change this property to something other than none or hidden.
  • {{ Xref_cssinitial() }}: {{ Cssxref("none") }}
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified for each individual property

Syntax

Formal grammar: <border-style>{1,4} 
                where <border-style> is none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
 
border-style: style                  /* One-value syntax   */  E.g. border-style: dashed; 
border-style: horizontal vertical    /* Two-value syntax   */  E.g. border-style: dotted solid; 
border-style: top vertical bottom    /* Three-value syntax */  E.g. border-style: hidden double dashed; 
border-style: top right bottom left  /* Four-value syntax  */  E.g. border-style: none solid dotted dashed; 
border-style: inherit

Values

<border-style>
Is a keyword describing the style of the bottom 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-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-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-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") }} .
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.

Examples

{{ CSSRefExampleLink("border") }}

element { 
  border-width: 1px;
  border-style: solid;
  border-color: black;
}

Specifications

Specification Status Comment
CSS Backgrounds and Borders Module Level 3 {{ Spec2('CSS3 Backgrounds') }} No change
CSS 2.1 {{ Spec2('CSS2.1') }} Added the 2-, 3- and 4-value syntaxes
CSS 1 {{ Spec2('CSS1') }}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support {{ CompatGeckoDesktop("1.0") }} 1.0 4.0 3.5 1.0
Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatGeckoMobile("1.9.2") }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

  • The border-related shorthand CSS properties: {{ Cssxref("border") }}, {{ Cssxref("border-width") }}, {{ Cssxref("border-color") }}, {{ Cssxref("border-radius") }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>border-style</code> <a href="/en/CSS" title="CSS">CSS</a> property is a shorthand property for setting the line style for all four sides of the elements border.</p>
<div class="note">
  <strong>Note:</strong> The default value of <code>border-style</code> is <code>none</code>. This means that if you change the {{ Cssxref("border-width") }} and the <span style="white-space:nowrap;">{{ Cssxref("border-color") }},</span> you will not see the border unless you change this property to something other than <code>none</code> or <code>hidden</code>.</div>
<ul class="cssprop">
  <li><dfn>{{ Xref_cssinitial() }}:</dfn> {{ Cssxref("none") }}</li>
  <li><dfn>Applies to:</dfn> all elements</li>
  <li><dfn>{{ Xref_cssinherited() }}:</dfn> no</li>
  <li><dfn>Media:</dfn> {{ Xref_cssvisual() }}</li>
  <li><dfn>{{ Xref_csscomputed() }}:</dfn> as specified for each individual property</li>
</ul>
<h2 id="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">Formal grammar: &lt;border-style&gt;{1,4} 
                where &lt;border-style&gt; is none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
</pre>
<pre> 
border-style: <em>style</em> <em>                 /* One-value syntax   */</em>  E.g. border-style: dashed; 
border-style: <em>horizontal</em> <em>vertical</em> <em>   /* Two-value syntax   */ </em> E.g. border-style: dotted solid; 
border-style: <em>top</em> <em>vertical</em> <em>bottom </em><em>   /* Three-value syntax */ </em> E.g. border-style: hidden double dashed; 
border-style: <em>top</em> <em>right</em> <em>bottom</em> <em>left </em><em> /* Four-value syntax  */ </em> E.g. border-style: none solid dotted dashed; 
border-style: inherit</pre>
<h3 id="Values">Values</h3>
<dl>
  <dt>
    &lt;border-style&gt;</dt>
  <dd>
    Is a keyword describing the style of the bottom 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-style:none; background-color:palegreen;">
               </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-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-style:hidden; background-color:palegreen;">
               </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-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-style:dotted; background-color:palegreen;">
               </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-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-style:dashed; background-color:palegreen;">
               </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-style:solid; background-color:palegreen;">
               </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-style:double; background-color:palegreen;">
               </div>
          </td>
          <td style="vertical-align:middle;">Displays two straight lines that add up to the pixel amount defined as {{ cssxref("border-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-style:groove; background-color:palegreen;">
               </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-style:ridge; background-color:palegreen;">
               </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-style:inset; background-color:palegreen;">
               </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-style:outset; background-color:palegreen;">
               </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>
</dl>
<h2 id="Examples">Examples</h2>
<p>{{ CSSRefExampleLink("border") }}</p>
<pre class="brush: css">element { 
  border-width: 1px;
  border-style: solid;
  border-color: black;
}
</pre>
<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><a class="external" href="http://www.w3.org/TR/css3-background/#the-border-style" title="http://www.w3.org/TR/css3-background/#the-border-style">CSS Backgrounds and Borders Module Level 3</a></td>
      <td>{{ Spec2('CSS3 Backgrounds') }}</td>
      <td>No change</td>
    </tr>
    <tr>
      <td><a class="external" href="http://www.w3.org/TR/CSS21/box.html#border-style-properties" title="http://www.w3.org/TR/CSS21/box.html#border-style-properties">CSS 2.1</a></td>
      <td>{{ Spec2('CSS2.1') }}</td>
      <td>Added the 2-, 3- and 4-value syntaxes</td>
    </tr>
    <tr>
      <td><a class="external" href="http://www.w3.org/TR/CSS1/#border-style" title="http://www.w3.org/TR/CSS1/#border-style">CSS 1</a></td>
      <td>{{ Spec2('CSS1') }}</td>
      <td> </td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Firefox (Gecko)</th>
        <th>Chrome</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatGeckoDesktop("1.0") }}</td>
        <td>1.0</td>
        <td>4.0</td>
        <td>3.5</td>
        <td>1.0</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>Android</th>
        <th>IE Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatGeckoMobile("1.9.2") }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li>The border-related shorthand CSS properties: {{ Cssxref("border") }}, {{ Cssxref("border-width") }}, {{ Cssxref("border-color") }}, {{ Cssxref("border-radius") }}</li>
</ul>
Revert to this revision