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

Mary-Kate Olsen
Release: 2024-11-03 15:23:02
Original
236 people have browsed it

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>
Copy after login

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>
Copy after login

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template