Little Web Hut

CSS 2.1 Reference: border-spacing Property

CSS border-spacing Property
Syntax
selector {border-spacing: value1 value2;}
  • value1 is specified by using a length.
  • value2 is OPTIONAL. It is specified by using a length.
(OR)
selector {border-spacing: value;}
  • value is specified by using the keyword inherit.
Usage

The border-spacing property is used to specify the distance between table borders.

  • One or two length values may be specifies as follows. Note: Negative length values are not permitted.
    • If 1 length value is specified - Both the horizontal and vertical spacing distances are set with this single value.
    • If 2 length values are specified - The first value specifies the horizontal spacing and the second value the vertical spacing.

CSS Example: The border-spacing property is set by specifying 2 length values.
  th, td {border: thin solid;}
  table {display: table;
         border-collapse: separate;
         border-spacing: 20px 5px;
         border: thin solid;
         width: 400px;
  }
Test It HTML StyleTest It XHTML StyleTest It HTML5 Style

Keywords
  • inherit - A single inherit keyword is used to specify that the values for this property should be taken from the parent element. If inherit is used with the root element, then the initial values for this property will be used. When the inherit keyword is used, no other property values are allowed.
Applies To Elements that have a display property value of table or inline-table.
Inherited Yes
Initial Value 0


border-spacing Property Examples
Test It HTML StyleTest It HTML StyleTest It HTML5 StyleThe border-spacing property is set by specifying 2 length values.