Skip to content

Element.getCssPropertyValue method

Element › getCssPropertyValue

Official

Gets the value of a CSS property of the element.

Signature:

getCssPropertyValue(property: string, pseudoElement?: string | undefined): string

Parameters:

Parameter Type Description
property string The property to get the value of.
pseudoElement? string | undefined The pseudo-element to get the value of.

Returns: stringThe value of the CSS property.

Example:

const element = document.body.createEl('p');
element.style.color = 'red';
console.log(element.getCssPropertyValue('color')); // rgb(255, 0, 0)
console.log(element.getCssPropertyValue('color', ':after')); // rgb(255, 0, 0)