border-style

  • Revision slug: Web/CSS/border-style
  • Revision title: border-style
  • Revision id: 483817
  • Created:
  • Creator: jswisher
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef("CSS Borders") }}

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.

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

Syntax

Formal syntax: {{csssyntax("border-style")}}
border-style: style                  /* One-value syntax   */  E.g. border-style: dashed; 
border-style: vertical horizontal    /* Two-value syntax   */  E.g. border-style: dotted solid; 
border-style: top horizontal 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

<br-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

Here is the live example :

http://jsfiddle.net/UBCWc/

{{ EmbedLiveSample('Example_for_border-color_and_border-style', '', '', 'en-US/docs/Web/CSS/Web/CSS/border-color') }}

Specification Status Comment
{{ SpecName('CSS3 Backgrounds', '#border-style', 'border-style') }} {{ Spec2('CSS3 Backgrounds') }} No change
{{ SpecName('CSS2.1', 'box.html#propdef-border-style', 'border-style') }} {{ Spec2('CSS2.1') }} Added the 2-, 3- and 4-value syntaxes
{{ SpecName('CSS1', '#border-style', 'border-style') }} {{ Spec2('CSS1') }}  

Specifications

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{ CompatGeckoDesktop("1.0") }} 4.0 3.5 1.0
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatGeckoMobile("1.9.2") }} {{ 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("CSS Borders") }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>border-style</code> <a href="/en-US/docs/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>&nbsp;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>
<p>{{cssbox("border-style")}}</p>
<h2 id="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("border-style")}}
</pre>
<pre>
border-style: <em>style</em> <em>                 /* One-value syntax   */</em>  E.g. border-style: dashed; 
border-style: <em>vertical</em> <em>horizontal</em> <em>   /* Two-value syntax   */ </em> E.g. border-style: dotted solid; 
border-style: <em>top</em> <em>horizontal</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>
  <code>&lt;br-style&gt;</code></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;">
       &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-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;">
       &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-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;">
       &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-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;">
       &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-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-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") }} .</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;">
       &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-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-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-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>
</dl>
<h2 id="Examples">Examples</h2>
<p>Here is the live example :</p>
<p><a href="http://jsfiddle.net/UBCWc/">http://jsfiddle.net/UBCWc/</a></p>
<p>{{ EmbedLiveSample('Example_for_border-color_and_border-style', '', '', 'en-US/docs/Web/CSS/Web/CSS/border-color') }}</p>
<table class="standard-table" style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', Lucida, Arial, Helvetica, sans-serif; font-size: 14px; font-weight: normal; line-height: 1.572;">
 <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', '#border-style', 'border-style') }}</td>
   <td>{{ Spec2('CSS3 Backgrounds') }}</td>
   <td>No change</td>
  </tr>
  <tr>
   <td>{{ SpecName('CSS2.1', 'box.html#propdef-border-style', 'border-style') }}</td>
   <td>{{ Spec2('CSS2.1') }}</td>
   <td>Added the 2-, 3- and 4-value syntaxes</td>
  </tr>
  <tr>
   <td>{{ SpecName('CSS1', '#border-style', 'border-style') }}</td>
   <td>{{ Spec2('CSS1') }}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
<p>Specifications</p>
<h2 id="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>{{ CompatGeckoDesktop("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>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>{{ CompatGeckoMobile("1.9.2") }}</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