Style outlineWidth attribute

Definition and usage

outlineWidth Set or return the width of the outline around the element.

The outline is a line around the element. It is displayed around the element's margin. However, it is different from the border property.

The outline is not part of the element's size, so the width and height attributes do not include the outline width.

See also:

CSS Tutorial:CSS kontur

CSS Reference Manual:outline property

HTML DOM Reference Manual:outline property

Example

Example 1

Change the outline width of the <div> element:

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

Try it yourself

Example 2

Use the "thick" value to change the outline width of the <div> element:

document.getElementById("myDiv").style.outlineWidth = "thick";

Try it yourself

Example 3

Return the width of the <div> element's outline:

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

Try it yourself

Syntax

Return outlineWidth attribute:

object.style.outlineWidth

Set outlineWidth attribute:

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

Attribute value

Value Description
thin Define thin outline.
medium Define medium outline. Default.
thick Define thick outline.
length Outline width measured in length units.
initial Set this property to its default value. See initial.
inherit Inherit this property from its parent element. See inherit.

Technical details

Default value: medium
Return value: String representing the width of the element's outline.
CSS version: CSS2

Browserstøtte

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