Home >Web Front-end >CSS Tutorial >How to Remove Indentation from Unordered Lists in CSS?

How to Remove Indentation from Unordered Lists in CSS?

Linda Hamilton
Linda HamiltonOriginal
2024-11-17 09:06:03805browse

How to Remove Indentation from Unordered Lists in CSS?

Removing Indentation from Unordered Lists

When attempting to remove all indentation from a

    element, it is common to encounter difficulties despite setting margin, padding, and text-indent to 0. While setting text-indent to a negative value appears to resolve the issue, it is not the optimal solution.

    Instead, it is recommended to set both the list style and left padding to "none":

    ul {
        list-style: none;
        padding-left: 0;
    }

    This approach effectively removes the default indentation associated with

      elements, resulting in a flush left-aligned list.

      Example:

      <ul>
        <li>a</li>
        <li>b</li>
        <li>c</li>
      </ul>

      Output:

      * a
      * b
      * c

      The above is the detailed content of How to Remove Indentation from Unordered Lists in CSS?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn