Style borderTopWidth Property

Definition and Usage

borderTopWidth Sets or returns the width of the element's border.

See Also:

CSS Tutorial:CSS Borders

CSS Reference Manual:border-top-width Property

HTML DOM Reference Manual:border Property

Example

Example 1

Changes the top border width of the <div> element to 10px:

document.getElementById("myDiv").style.borderTopWidth = "10px";

Try It Yourself

Example 2

Changes the top border width of the <div> element to thin:

document.getElementById("myDiv").style.borderTopWidth = "thin";

Try It Yourself

Example 3

Returns the width of the top border of the <div> element:

alert(document.getElementById("myDiv").style.borderTopWidth);

Try It Yourself

Syntax

Returns the borderTopWidth property:

object.style.borderTopWidth

Sets the borderTopWidth property:

object.style.borderTopWidth = "thin|medium|thick|length|initial|inherit"
Value Description
thin Defines thin borders.
medium Defines medium borders. Default.
thick Defines thick borders.
length Border width measured in length.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default Value: medium
Return Value: A string representing the width of the element's top border.
CSS Version: CSS1

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support