11 out of 15 rated this helpful - Rate this topic

border property

Specifies the properties of a border drawn around an object.

CSS Backgrounds and Borders Module Level 3, Section 4.4

Syntax

border: <border-width> || <border-style> || <border-color>

Property values

One or more of the following space-delimited values:

border-width

Any of the range of width values available to the border-width property.

border-style

Any of the range of style values available to the border-style property.

border-color

Any of the range of color values available to the border-color property.

CSS information

Applies ToAll elements
Mediavisual
Inheritedno
Initial Value(see individual properties)

Standards information

Remarks

The border property is a composite property that sets the width, style, and color values for all four sides of an object. Unlike the shorthand margin and padding properties, the border property can't set different values on the four borders. To do that, one or more of the other border properties (that is, border-bottom, border-left, and so on) must be used.

You must specify a style when specifying a width or color; otherwise, the border does not render.

All individual border properties not set by the composite border property are set to their default values. For example, the default value for width is "medium".

The declaration "border: thin" is identical to "border: thin none"; the default value for the border color is the same as the text color if one is not initially set. Therefore, not only does this declaration set width to "thin", it also clears any style or color values previously set.

Setting a border to 0 or omitting the border property causes no border to be displayed. Supplying the border property without a value defaults to a single border.

If a color is not specified, the text color is used.

For more information about supported colors, see the Color Table.

Examples

The following examples use the border CSS property and the border scripting property to specify the composite border properties.

This example uses a call to an embedded (global) style sheet to modify the border attribute.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/border_h.htm


<head>
<style>
.applyBorder {
  border: 0.2cm groove orange;
}
.removeBorder {
  border: none;
}
</style>
</head>

<body>

<table>
  <tr>
    <td onmouseout="this.className='removeBorder'" onmouseover="this.className='applyBorder'">
    <img alt="sphere" src="sphere.jpg"></td>
  </tr>
</table>


This example uses inline scripting to modify the border property.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/border_s.htm


<td onmouseover="this.style.border='0.2cm groove pink'">

See also

CSSStyleDeclaration
currentStyle
defaults
runtimeStyle
style
CSS Enhancements in Internet Explorer 6

 

 

Send comments about this topic to Microsoft

Build date: 11/29/2012

Community Additions

ADD
© 2013 Microsoft. All rights reserved.