HTML <ul> style Attribute

The style attribute on a <ul> tag assigns a unique style to the unordered list. A style contains one or more CSS property/value pairs that define the appearance of the ul element.

Example

#

A style attribute on a <ul> element.

  • Vincent Van Gogh
  • Paul Cézanne
  • Claude Monet
<ul style="list-style-type: circle;">
  <li>Vincent Van Gogh</li>
  <li>Paul Cézanne</li>
  <li>Claude Monet</li>
</ul>

Using style

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.


Syntax

<ul style="CSS-styles">

Values

#

Value Description
CSS-styles One or more CSS property/value pairs separated by semicolons (;).

More Examples

A style attribute on a <ul> element.
Clicking the button toggles item bullet type.

  • Vincent Van Gogh
  • Paul Cézanne
  • Claude Monet

<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>

Code explanation

The style attribute assigns a different list style type to the <ul> element.

Clicking the button calls JavaScript which changes the list style type.


Browser support

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

You may also like

 Back to <ul>
Guides