Ora

How to make an unordered list without bullets in HTML?

Published in HTML CSS Styling 4 mins read

To create an unordered list without bullets in HTML, you apply the CSS property list-style: none; to the <ul> element. This CSS declaration effectively removes the default bullet points, allowing you to style the list items as desired.

The Core CSS Property: list-style: none;

The list-style property in CSS is a shorthand for list-style-type, list-style-image, and list-style-position. By setting list-style: none; on an unordered list (<ul>), you instruct the browser not to display any marker (like a disc, circle, or square) next to the list items. This is the fundamental technique for achieving a bullet-free list.

Methods to Remove List Bullets

There are several ways to apply list-style: none; to your unordered list, each with its own use case and best practices.

1. Inline CSS (Directly on the <ul> Tag)

This method involves applying the CSS style directly within the HTML <ul> tag using the style attribute. It's quick for single instances but generally not recommended for large projects due to poor maintainability.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Inline Styled List</title>
</head>
<body>
    <h2>Our Features (Inline Style)</h2>
    <ul style="list-style: none; padding-left: 0;">
        <li>Feature One</li>
        <li>Feature Two</li>
        <li>Feature Three</li>
    </ul>
    <p>
        *Note: `padding-left: 0;` is often added to remove default browser padding that pushes list items to the right.*
    </p>
</body>
</html>
  • Pros: Quick for isolated instances, overrides other styles easily.
  • Cons: Not maintainable, mixes content and presentation, difficult to update across multiple lists.

2. Internal CSS (Within the <head> Section)

With internal CSS, you define styles within a <style> block in the <head> section of your HTML document. This is suitable for single-page applications or when styles are unique to a particular HTML file.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Internal Styled List</title>
    <style>
        .no-bullets {
            list-style: none;
            padding-left: 0; /* Optional: removes default indentation */
        }
    </style>
</head>
<body>
    <h2>Our Services (Internal Style)</h2>
    <ul class="no-bullets">
        <li>Service A</li>
        <li>Service B</li>
        <li>Service C</li>
    </ul>
</body>
</html>
  • Pros: Centralized styling for a single HTML file, better separation than inline styles.
  • Cons: Styles are not reusable across multiple HTML files.

3. External CSS (Recommended for Maintainability)

This is the most widely recommended and efficient method for styling in web development. You define your CSS rules in a separate .css file and link it to your HTML documents. This allows for clean separation of concerns and easy management of styles across an entire website. As often seen in professional web development, there are typically numerous CSS classes in play, making external stylesheets the most practical approach.

Example:

First, create a file named styles.css (or any name you prefer) in the same directory as your HTML file:

styles.css:

/* styles.css */
.no-bullets-list {
    list-style: none;
    padding-left: 0; /* Optional: removes default indentation */
    margin: 0; /* Optional: removes default margin */
}

/* Example styling for list items if needed */
.no-bullets-list li {
    background-color: #f0f0f0;
    margin-bottom: 5px;
    padding: 8px;
    border-radius: 4px;
}

Then, link this stylesheet in your HTML document:

index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>External Styled List</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h2>Our Products (External Style)</h2>
    <ul class="no-bullets-list">
        <li>Product X</li>
        <li>Product Y</li>
        <li>Product Z</li>
    </ul>

    <h2>Navigation Menu Example</h2>
    <nav>
        <ul class="no-bullets-list">
            <li><a href="#home">Home</a></li>
            <li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
        </ul>
    </nav>
</body>
</html>
  • Pros: Excellent for site-wide consistency, highly maintainable, separation of concerns (HTML for content, CSS for presentation), improved page load times (browser caches CSS file).
  • Cons: Requires an extra HTTP request to fetch the CSS file (minimal impact for modern web).

Comparison of Methods

Feature Inline CSS Internal CSS External CSS
Declaration style attribute on element <style> tags in <head> Separate .css file
Reusability None Single page only Across multiple pages/entire site
Maintainability Poor Fair Excellent
Specificity Highest High (can be overridden) Moderate (managed with selectors)
Best For Quick tests, unique single cases Single-page apps, theme overrides Large websites, consistent styling

When to Use a Bullet-less List

Removing bullets from an unordered list is common in modern web design for several reasons:

  • Navigation Menus: <ul> and <li> elements are semantically appropriate for navigation, even when styled horizontally without bullets.
  • Footer Links: Similar to navigation, footers often contain lists of links that don't require visual bullets.
  • Tag Clouds or Category Lists: Lists of tags or categories often appear without traditional bullets, using custom styling instead.
  • Image Galleries: A list of images, each within an <li>, can be styled as a grid without bullet markers.
  • Feature Lists: When features are presented with custom icons or styled backgrounds instead of default bullets.

Even when bullets are removed, using <ul> and <li> maintains the semantic meaning of a list, which is important for accessibility and search engine optimization (SEO). Screen readers, for example, will still identify the structure as a list.

For further reading on list styling, refer to the MDN Web Docs on list-style.