A style attribute on a <ul> tag assigns a unique style to the list.
Its value is CSS that defines the appearance of the ul element.
A style attribute on a <ul> element.
<ul style="list-style-type: circle;">
<li>Vincent Van Gogh</li>
<li>Paul Cézanne</li>
<li>Claude Monet</li>
</ul>
The style attribute specifies the style, i.e. look and feel, of the <ul> 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 <ul> element only.
<ul style="CSS-styles">
Value | Description |
---|---|
CSS-styles | One or more CSS property/value pairs separated by semicolons (;). |
A style attribute on a <ul> element.
Clicking the button toggles item bullet type.
<ul id="myul" style="list-style-type: circle;">
<li>Vincent Van Gogh</li>
<li>Paul Cézanne</li>
<li>Claude Monet</li>
</ul>
<br />
<button onclick="toggle();">Toggle class</button>
<script>
let toggle = () => {
let element = document.getElementById("myul");
if (element.style.listStyleType === "circle") {
element.style.listStyleType = "square";
} else {
element.style.listStyleType = "circle";
}
}
</script>
The style attribute assigns a different list style type to the <ul> element.
Clicking the button calls JavaScript which changes the list style type.
Here is when style support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
1.0 | Sep 2002 |
IE/Edge
|
1.0 | Aug 1995 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |
Back to <ul>