A style attribute on a <summary> tag assigns a unique style to the element.
Its value is CSS that defines the appearance of the summary element.
A style attribute on a <summary> element.
You sold 125 shares of MSFT at 11:29 AM
You bought 200 shares of GOOG at 11:26 AM
<details>
<summary style="background: #edf2ff; padding: 15px; outline: none;
border-radius: 50px;">Order 4A801</summary>
<p>You sold 125 shares of MSFT at 11:29 AM</p>
<p>You bought 200 shares of GOOG at 11:26 AM</p>
</details>
The style attribute specifies the style, i.e. look and feel, of the <summary> element.
A style contains any number of CSS property/value pairs, separated by semicolons (;).
The style attribute overrides any other style that was defined in a <style> tag or an external CSS file.
This inline styling affects the current <summary> element only.
<summary style="CSS-styles">
Value | Description |
---|---|
CSS-styles | One or more CSS property/value pairs separated by semicolons (;). |
A style attribute on a <summary> element.
Clicking the button toggles the background color.
You sold 125 shares of MSFT at 11:29 AM
You bought 200 shares of GOOG at 11:26 AM
<details>
<summary id="mysummary"
style="background: lightblue; outline: none;padding: 15px;
border-radius: 50px;">Order 4A801</summary>
<p>You sold 125 shares of MSFT at 11:29 AM</p>
<p>You bought 200 shares of GOOG at 11:26 AM</p>
</details>
<br />
<button onclick="toggle();">Toggle style</button>
<script>
let toggle = () => {
let element = document.getElementById("mysummary");
if (element.style.backgroundColor === "lightblue") {
element.style.backgroundColor = "lavender";
} else {
element.style.backgroundColor = "lightblue";
}
}
</script>
The style attribute assigns a background color to the <summary> element.
Clicking the button calls JavaScript which toggles the background to another color.
Here is when style support started for each browser:
Chrome
|
12.0 | Jun 2011 |
Firefox
|
48.0 | Aug 2016 |
IE/Edge
|
Not supported | |
Opera
|
15.0 | May 2013 |
Safari
|
6.0 | Jul 2012 |
Back to <summary>