Home  >  Article  >  Web Front-end  >  How to Remove the Period After Ordered List Numbers in HTML and CSS?

How to Remove the Period After Ordered List Numbers in HTML and CSS?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-03 15:23:02244browse

How to Remove the Period After Ordered List Numbers in HTML and CSS?

Ordered Lists in HTML and CSS: Removing the Period

Creating an ordered list without the period after the numbers is possible using CSS. While you may assume it's not feasible, let's explore how you can achieve this.

To remove the period, style the list as such:

<code class="css">ol.custom {
  list-style-type: none;
  margin-left: 0;
}</code>

To create custom numbers, use the following code:

<code class="css">ol.custom > li {
  counter-increment: customlistcounter;
}

ol.custom > li:before {
  content: counter(customlistcounter) " ";
  font-weight: bold;
  float: left;
  width: 3em;
}</code>

This will display custom numbers before each list item.

Keep in mind that this solution relies on the :before pseudo-selector, which may not work in older browsers like IE6 and IE7. To address this, use an additional CSS rule that targets these browsers specifically:

<code class="css">ol.custom {
  *list-style-type: decimal; /* targets IE6 and IE7 only */
}</code>

The above is the detailed content of How to Remove the Period After Ordered List Numbers in HTML and 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