MathMLElement: attributeStyleMap property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The attributeStyleMap read-only property of the MathMLElement 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 MathMLElement 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:

html
<math>
  <mrow>
    <mi>f</mi>
    <mo stretchy="false">(</mo>
    <mi id="el" style="border-top: 1px solid blue; color: red;">x</mi>
    <mo stretchy="false">)</mo>
    <mo>=</mo>
    <mi>x</mi>
  </mrow>
</math>
<div id="output"></div>
css
#el {
  font-size: 16px;
}

#output {
  white-space: pre-line;
}
js
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

Specification
CSS Typed OM Level 1
# dom-elementcssinlinestyle-attributestylemap

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
attributeStyleMap
Chrome – Full support
Chrome 109 (Release date: 2023-01-10)
footnote Full support
Edge – Full support
Edge 109 (Release date: 2023-01-12)
footnote Full support
Firefox – No support
Firefox
footnote
footnote See bug 1278697
Opera – Full support
Opera 95 (Release date: 2023-02-01)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 109 (Release date: 2023-01-10)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote
footnote See bug 1278697
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16.4 (Release date: 2023-03-27)
footnote Full support
Samsung Internet – Full support
Samsung Internet 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 109 (Release date: 2023-01-10)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16.4 (Release date: 2023-03-27)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

See also