border-style

  • Revision slug: CSS/border-style
  • Revision title: border-style
  • Revision id: 20759
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 3 words added, 3 words removed

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.

The default value of border-style is none. This meant 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") }} or as individual Properties.
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as individual properties

Syntax

border-style: style                      /* One-value syntax */
border-style: horizontal vertical        /* Two-value syntax */
border-style: top vertical bottom        /* Three-value syntax */
border-style: top right bottom left      /* Four-value syntax */
border-style: inherit

where:

style
Is a <border-style> denoting the style of the border to apply to all four edges. It is used only in the one-value syntax.
horizontal
Is a <border-style> denoting the style of the border to apply to all horizontal edges, that is the top and bottom edges. It is used only in the two-value syntax.
vertical
Is a <border-style> denoting the style of the border to apply to all vertical edges, that is the right and left edges. It is used only in the two- and three-value syntaxes.
top
Is a <border-style> denoting the style of the border to apply to the top edge. It is used only in the three- and four-value syntaxes.
bottom
Is a <border-style> denoting the style of the border to apply to the bottom edge. It is used only in the three- and four-value syntaxes.
right
Is a <border-style> denoting the style of the border to apply to the top edge. It is used only in the four-value syntax.
left
Is a <border-style> denoting the style of the border to apply to the top edge. It is used only in the four-value syntax.
inherit
Is a keyword indicating that all four values are inherited from their parent's element calculated value.

and:

<border-style> 
Is a keyword describing the style of the bottom border. It can have the following values:
none
fake
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
fake
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
fake
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
fake
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
fake
Displays a single, straight, solid line.
double
fake
Displays two straight lines that add up to the pixel amount defined as {{ cssxref("border-width") }} .
groove
fake
Displays a border leading to a carved effect. It is the opposite of ridge.
ridge
fake
Displays a border with a 3D effect, like if it is coming out of the page. It is the opposite of groove.
inset
fake
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
fake

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;
}

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() }}

Specifications

See also

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

{{ languages( { "de": "de/CSS/border-style", "es": "es/CSS/border-style", "fr": "fr/CSS/border-style", "ja": "ja/CSS/border-style", "pl": "pl/CSS/border-style" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2>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">The default value of <code>border-style</code> is <code>none</code>. This meant 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 <code>none</code> or <code>hidden</code>.</div>
<ul> <li>{{ Xref_cssinitial() }}: {{ Cssxref("none") }} or as individual Properties.</li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: no</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: as individual properties</li>
</ul>
<h2>Syntax</h2>
<pre class="eval syntaxbox">border-style: <em>style</em>                    <em>  /* One-value syntax */</em>
border-style: <em>horizontal</em> <em>vertical</em>        <em>/* Two-value syntax */</em>
border-style: <em>top</em> <em>vertical</em> <em>bottom   </em><em>     /* Three-value syntax */</em>
border-style: <em>top</em> <em>right</em> <em>bottom</em> <em>left </em><em>     /* Four-value syntax */</em>
border-style: inherit
</pre>
<p>where:</p>
<dl> <dt>style</dt> <dd>Is a <code>&lt;border-style&gt;</code> denoting the style of the border to apply to all four edges. It is used only in the one-value syntax.</dd> <dt><em>horizontal</em></dt> <dd>Is a<code> &lt;border-style&gt; </code>denoting the style of the border to apply to all horizontal edges, that is the top and bottom edges. It is used only in the two-value syntax.</dd> <dt><em>vertical</em></dt> <dd>Is a <code>&lt;border-style&gt;</code> denoting the style of the border to apply to all vertical edges, that is the right and left edges. It is used only in the two- and three-value syntaxes.</dd> <dt><em>top</em></dt> <dd>Is a <code>&lt;border-style&gt;</code> denoting the style of the border to apply to the top edge. It is used only in the three- and four-value syntaxes.</dd> <dt><em>bottom</em></dt> <dd>Is a <code>&lt;border-style&gt;</code> denoting the style of the border to apply to the bottom edge. It is used only in the three- and four-value syntaxes.</dd> <dt><em>right</em></dt> <dd>Is a <code>&lt;border-style&gt;</code> denoting the style of the border to apply to the top edge. It is used only in the four-value syntax.</dd> <dt><em>left</em></dt> <dd>Is a <code>&lt;border-style&gt;</code> denoting the style of the border to apply to the top edge. It is used only in the four-value syntax.</dd> <dt>inherit</dt> <dd>Is a keyword indicating that all four values are inherited from their parent's element calculated value.</dd>
</dl>
<p>and:</p>
<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;"><span style="display:none;">fake</span></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;"><span style="display:none;">fake</span></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;"><span style="display:none;">fake</span></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;"><span style="display:none;">fake</span></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;"><span style="display:none;">fake</span></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;"><span style="display:none;">fake</span></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;"><span style="display:none;">fake</span></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;"><span style="display:none;">fake</span></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;"><span style="display:none;">fake</span></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;"><span style="display:none;">fake</span></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>Examples</h2>
<p>{{ CSSRefExampleLink("border") }}</p>
<pre>element { 
  border-width: 1px;
  border-style: solid;
  border-color: black;
}
</pre>
<h2>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>Specifications</h2>
<ul> <li><a class="external" href="http://www.w3.org/TR/CSS21/box.html#border-style-properties">CSS 2.1 Box model #border-style</a></li>
</ul>
<h2>See also</h2>
<ul> <li>The border-related shorthand CSS properties: {{ Cssxref("border") }}, {{ Cssxref("border-width") }}, {{ Cssxref("border-color") }}, {{ Cssxref("border-radius") }}</li>
</ul>
<p>{{ languages( { "de": "de/CSS/border-style", "es": "es/CSS/border-style", "fr": "fr/CSS/border-style", "ja": "ja/CSS/border-style", "pl": "pl/CSS/border-style" } ) }}</p>
Revert to this revision