Easy Tutorial
❮ Prop Datetime Local Value Jsref Italics ❯

HTML DOM style Attribute

Element Object

Example

Modify the color of an element:


Definition and Usage

The style attribute returns the value of the element's style attribute.

The style attribute returns a CSSStyleDeclaration object.

The CSSStyleDeclaration object contains all the inline properties of the element, but does not include external styles set in the <head> section.


Browser Support

Attribute
style Yes Yes Yes Yes Yes

Syntax

Get the style attribute:

element.style.property

Set the style attribute:

element.style.property = value

Technical Details

| Return Value: | Returns the value of the specified property. For example: element.style.borderBottom = "2px solid red" | | --- | --- |


More Examples

Example

Get the value of the element's style attribute:

let value = document.getElementById("myP").style.borderTop;

Element Object

❮ Prop Datetime Local Value Jsref Italics ❯