There are a couple of ways we can make an HTML list without bullets. We can do it through CSS, or we can do it in HTML with the style attribute. Let’s look at the style attribute inside an HTML element.
- Blue
- Green
- Orange
- Yellow
As you can see in the code above, we can set the list-style-type property of the unordered list to none to make this HTML list not have bullet points.
The code above will display this:
- Blue
- Green
- Orange
- Yellow
We can also do this by setting the list-style-type property to none in a style tag. See how this is done below.
- Blue
- Green
- Orange
- Yellow
We prefer to have all our styles grouped together in a style tag, or in a separate CSS sheet, so we usually will go with the method above. But both examples will yield the same result.
Making an HTML List Without Bullets Using JavaScript
In this example, we will have an HTML list with bullet points to start. We will then provide a button for the user to remove the bullet points using JavaScript.
Here is the HTML code:
Here is a list of some colors.
- Blue
- Green
- Orange
- Yellow
- Pink
- Red
- Black
- Purple
- White
Remove bullets
We will add an onclick event to our button so that we can run a function. In the function, we will simply target the unordered list using the getElementById() method, and remove its bullet points using JavaScript, the style attribute, and the list-style-type property. Here is the code below:
function removeBulletPoints(){
document.getElementById("color-list").style.listStyleType = "none";
};
The final code and output for this example of how to make an HTML list without bullets using JavaScript is below:
Code Output:
Here is a list of some colors.
- Blue
- Green
- Orange
- Yellow
- Pink
- Red
- Black
- Purple
- White
Full Code:
Here is a list of some colors.
- Blue
- Green
- Orange
- Yellow
- Pink
- Red
- Black
- Purple
- White
Remove bullets