Latest web development tutorials
 

Style borderTopWidth Property

< Style Object

Example

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

document.getElementById("myDiv").style.borderTopWidth = "10px";
Try it Yourself »

Definition and Usage

The borderTopWidth property sets or returns the width of the top border of an element.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The borderTopWidth property is supported in all major browsers.


Syntax

Return the borderTopWidth property:

object.style.borderTopWidth

Set the borderTopWidth property:

object.style.borderTopWidth="thin|medium|thick|length|initial|inherit"

Property Values

Value Description
thin Defines a thin border
medium Defines a medium border. This is default
thick Defines a thick border
length The width of the border in length units
inherit The width of the top border is inherited from the parent element
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

Technical Details

Default Value: medium 
Return Value: A String, representing the width of an element's top border
CSS Version CSS1

More Examples

Example

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

document.getElementById("myDiv").style.borderTopWidth = "thin";
Try it Yourself »

Example

Return the width of the top border of a <div> element:

alert(document.getElementById("myDiv").style.borderTopWidth);
Try it Yourself »

Related Pages

CSS tutorial: CSS Border

CSS reference: border-top-width property

HTML DOM reference: border property


< Style Object