border-style

  • Revision slug: CSS/border-style
  • Revision title: border-style
  • Revision id: 20789
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment one or more formatting changes

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.
<style type="text/css"></style>
  • {{ Xref_cssinitial() }}: {{ Cssxref("none") }}
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified for each individual property

Syntax

 

 

<style type="text/css"></style>
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

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.

Values

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

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

{{ 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"><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>
<nobr>
<style type="text/css"><![CDATA[.cssprop {
  display:table;
  padding: 0.4em;
  border-left:0.15em solid;
  background-color:#eeeeff
}
.cssprop li {
 display:table-row;
 padding: 3px;
 margin:0;
}
.cssprop li dfn {
  display:table-cell;
  padding: 0 5px;
  border-bottom: none;
  cursor:inherit;
}
]]></style>
<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>
</nobr>
<p><nobr></nobr></p><nobr>
<h2>Syntax</h2>
<p> </p>
<p>  </p><style type="text/css"><![CDATA[.twopartsyntaxbox {
  border:1px solid #cccccc;
  border-bottom: none; 
  margin-bottom:0;
  background-color:#ffe;
  border-top-right-radius:1em;
  border-top-left-radius:1em;
}
.twopartsyntaxbox + pre {
  border:1px solid #cccccc;
  border-bottom-right-radius:1em;
  border-bottom-left-radius:1em;
  border-top:none;
  margin-top:0;
}
	
	
	
	]]></style>

<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>
<div style="font-size: 0.9em;"> <p style="float:left; margin:0:">where:</p> <dl style="padding-left:6em;"> <dt style="float:left;width:7.5em"><em>style</em></dt> <dd style="padding-left:7.5em">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 style="float:left;width:7.5em"><em>horizontal</em></dt> <dd style="padding-left:7.5em">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 style="float:left;width:7.5em"><em>vertical</em></dt> <dd style="padding-left:7.5em">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 style="float:left;width:7.5em"><em>top</em></dt> <dd style="padding-left:7.5em">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 style="float:left;width:7.5em"><em>bottom</em></dt> <dd style="padding-left:7.5em">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 style="float:left;width:7.5em"><em>right</em></dt> <dd style="padding-left:7.5em">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 style="float:left;width:7.5em"><em>left</em></dt> <dd style="padding-left:7.5em">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 style="float:left;width:7.5em"><code>inherit</code></dt> <dd style="padding-left:7.5em">Is a keyword indicating that all four values are inherited from their parent's element calculated value.</dd> </dl>
</div>
<h3>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;"><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 name="Specifications">Specifications</h2>
<table class="standard-table"> <thead> <tr style="background-color: rgb(255, 204, 255);"> <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>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>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></nobr>
Revert to this revision