<div id="myElement">
Check the developer tools to see the log in the console and to inspect this
div's style attributes.
</div>
<hr />
<button id="set-initial" type="button">Set initial</button>
<button id="reset" type="button">Reset</button>CSSKeywordValue / notebook
CSSKeywordValue
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
#myElement {
display: flex;
border: solid;
padding: 10px;
margin: 5px;
}const setInitialButton = document.querySelector("#set-initial");
setInitialButton.addEventListener("click", () => {
const myElementInlineStyles =
document.getElementById("myElement").attributeStyleMap;
myElementInlineStyles.set("display", new CSSKeywordValue("initial"));
console.log(`display: ${myElementInlineStyles.get("display").value}`);
});