border-top property
[This documentation is preliminary and is subject to change.]
Sets or retrieves the properties of the top border of the object.
![]() |
Syntax
border-top: [
<border-width>
||
<border-style>
||
<border-top-color>
]
Property values
A variable of type String that specifies or receives one or more of the following space-delimited values:
- border-width
-
Any of the range of width values available to the border-top-width property.
- border-style
-
Any of the range of style values available to the border-top-style property.
- border-top-color
-
Any of the range of color values available to the border-top-color property.
CSS information
| Applies To | All elements |
|---|---|
| Media | visual |
| Inherited | no |
| Initial Value |
Standards information
- CSS 2.1, Section 5.5.18
Remarks
The border-top property is a composite property that sets the width, color, and style values for the top border of an object.
All individual border properties not set by the composite border-top property are set to their default values. For example, the default value for width is medium.
If a color is not specified, the text color is used.
For more information about supported colors, see the Color Table.
As of Microsoft Internet Explorer 5.5, this property applies to inline elements. With earlier versions of Windows Internet Explorer, inline elements must have an absolute position or layout to use this property. Element layout is set by providing a value for the height property or the width property.
Examples
The following examples use the border-top attribute and the border-top property to specify the composite properties.
This example uses a call to an embedded (global) style sheet to change the attributes of the top border when an onmouseover event occurs.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/border-top.htm
<HEAD>
<STYLE>
TD { border-top:0.5cm solid yellow }
.change { border-top:0.5cm groove pink }
</STYLE>
</HEAD>
<BODY>
<TABLE>
<TR>
<TD onmouseover="this.className='change'"
onmouseout="this.className=''">
<IMG src="sphere.jpg">
</TD>
</TR>
</TABLE>
This example uses inline scripting to change the top border when an onmouseover event occurs.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/borderTop.htm
<TD onmouseover="this.style.borderTop='0.3cm groove yellow'">
See also
- CSSStyleDeclaration
- currentStyle
- defaults
- runtimeStyle
- style
- Reference
- border
- Other Resources
- CSS Enhancements in Internet Explorer 6
Build date: 3/14/2012
