A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attributeStyleMap below:

HTMLElement: attributeStyleMap property - Web APIs

HTMLElement: attributeStyleMap property

Limited availability

The attributeStyleMap read-only property of the HTMLElement interface returns a live StylePropertyMap object that contains a list of style properties of the element that are defined in the element's inline style attribute, or assigned using the style property of the HTMLElement interface via script.

Shorthand properties are expanded. If you set border-top: 1px solid black, the longhand properties (border-top-color, border-top-style, and border-top-width) are set instead.

The main difference between style property and attributeStyleMap property is that, the style property will return a CSSStyleDeclaration object, while the attributeStyleMap property will return a StylePropertyMap object.

Though the property itself is not writable, you could read and write inline styles through the StylePropertyMap object that it returns, just like through the CSSStyleDeclaration object that returns via the style property.

Value

A live StylePropertyMap object.

Examples

The following code snippet shows the relationship between the style attribute and the attributeStyleMap property:

<div id="el" style="border-top: 1px solid blue; color: red;">
  An example element
</div>
<div id="output"></div>
#el {
  font-size: 16px;
}

#output {
  white-space: pre-line;
}
const element = document.getElementById("el");
const output = document.getElementById("output");

for (const property of element.attributeStyleMap) {
  output.textContent += `${property[0]} = ${property[1][0].toString()}\n`;
}
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4