List Markers in CSS Styling

Is there a way to customize the appearance of list markers like changing their color, making them bold, or adjusting the size? Can I apply styling to list markers similar to fonts?

For instance:

  1. This is a list item.

Is it possible to style the number "1." uniquely without affecting the rest of the text?

I am aware of methods like changing the type to roman-lower or square using list-style-type, but these options do not provide the styling flexibility I need.

Answer â„–1

To achieve the desired style in ordered list items, it is essential to utilize pseudo elements in conjunction with a counter.

ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: my-counter;
}

ol li {
  position: relative;
  padding-left: 10px;
  counter-increment: my-counter;
}

ol li:before {
  content: counter(my-counter);
  display: inline-block;
  vertical-align: middle;
  color: red;
  margin-right: 10px;
}
<ol>
  <li>example</li>
  <li>example</li>
  <li>example</li>
  <li>example</li>
</ol>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

PHP/CSS: Backgrounds for DIVs have been implemented, but they appear to be transparent

Update: Check out the link for some old photos here: I have a PHP file where I am creating divs with images as backgrounds using the code below (within a while-loop): echo ' <div class="pic" style="background:url('.$directory.'/'.$ ...

What is the best way to align my content alongside my sidebar?

I am facing some challenges with my website layout because I used Bootstrap to integrate a sidebar. The sidebar has caused issues with the positioning of my content, and I'm struggling to align it properly next to the sidebar on the left side. Please ...

What is the best way to ensure that text highlighting appears consistent on all browsers?

I am facing an issue with the appearance of text highlighting between Chrome and Firefox browsers. Is there a way to ensure consistency in the appearance across all browsers? a { text-decoration: none; font-weight: 900; font-size: 4vw !impo ...

"Enhance your webpage with Flexslider and captivating stretched images

When working with Flexslider, I encountered a challenge where the image was being stretched to fit the width of the flexslider. I prefer the image to be displayed centered, keeping its original dimensions, and having a black background-color. Is there a ...

Convert a two-column layout on the web into a single-column layout for mobile devices, featuring dynamic

Is there a way to style this diagram with CSS that will work on IE11 and all major browsers? It seems like Flexbox doesn't support dynamic height. Do I need separate left and right columns for larger viewports and no columns for smaller viewports? ...

Incorporate blocks into the text input box, reminiscent of how email applications manage to field

Seeking assistance with coding a header for a compose message page in a web application, utilizing HTML, CSS, and JS. The main query is about how to implement the functionality of converting selected email addresses into a box, as showcased in the image b ...

Intermittent issues with ng-style functionality

I'm currently utilizing ng-style to dynamically change the background color of a container class (from a third party tallinn.css file). The color is fetched from the database. However, when I navigate through Angular's routing, the ng-style attri ...

How can you vertically center text without using table-cell and line-height?

I have a webpage at this link and I am trying to vertically align the text. Using table-cell causes all items to display in the same row, which is not what I want as shown in the image at this link. Setting a fixed line-height won't work either since ...

What is the best way to enhance the smoothness of transitioning to a different section on the same page in React by clicking an anchor tag (<a>

Background My current method involves an immediate jump to another section without any smooth transition. This is how I implement it: <a href="#go_middle">Go Middle</a> <div id="go_middle"&‌​gt;Hello There</div> ...

Guide on creating a div container that spans the full width of the HTML page with a horizontal scrollbar

I'm facing an issue where the div container is not extending over the entire HTML page with a horizontal scroll bar. Here's a visual representation of my problem: Image Despite using MathJax to display math formulas, the div container does not ...

The interaction between background-size: cover and background-position

I wanted to experiment with setting background-size: cover and testing out different background positions. Feel free to check out the live fiddle for a hands-on experience. HTML <div id="container"> </div> CSS #container { backgro ...

How can you convert every item in a list into its own distinct string?

I have a list of lists with some integer values: mylist=[[3, 95],[8, 92],[18, 25],[75, 78],[71, 84],-9999,[96, 50],[91, 70],-9999,[19, 60]] Each element in the list is a sublist, except for the -9999 values which are integers. If I want to convert each ...

django url path configuration

Hello, I am currently in the process of learning Django and attempting to create a basic site using django-cms. Below you will find the folder structure for my project along with some key code files: project_folder manage.py main_folder ...

Add CSS styling to every primeng dialog within my Angular application

Incorporating PrimeNG dialog into my Angular application has been a breeze. I've been able to customize the style of each individual dialog by utilizing ng-deep. For example, on my contact us page, I have the following files: contact.html contact.com ...

Create a Stylish Tilted Effect on Div Sides using CSS

I am attempting to create a specific shape using clip-path: polygon, but I am struggling to understand the documentation. The properties for this shape are unclear to me - what do the values represent in clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%) ...

css for floating labels in input and textarea using bootstrap

I have implemented the Bootstrap Float-label feature found at https://github.com/tonystar/float-label-css Note: I made some custom changes to suit my needs. Issues : 1) While clicking on an input, the float label functions correctly. However, the bootst ...

Utilize HTML to pre-load a font and incorporate it into your CSS styling

It is common knowledge that when we include the following code in our .css file: @font-face { font-family: "Akrobat-Regular"; src: url('/assets/Akrobat-Regular.otf') format("truetype"); } body { color: #1c1c1c ...

Problematic rendering of Bootstrap Navbar Toggle

As I work on creating a WordPress theme using Bootstrap 3, I encountered an issue with the navbar toggle when reducing the screen width for testing. The image displayed doesn't align with what I expected. While I suspect it might be a WordPress-relate ...

Customize Bootstrap Navbar to Enable Horizontal Scrolling Specifically for Dropdown Buttons

Specific requirements: - Only buttons should be horizontally scrollable - Dropdown of buttons should appear just below the button without shifting the paragraph below Things I have attempted: - Tried using overflow:hidden/auto, overflow-x:auto, and pos ...

CSS: Element with overflowing content fails to display even with the overflow set to visible

I'm trying to enhance a fixed toolbar by adding a dropdown menu, but the .toolbar-dropdown-menu component isn't displaying correctly, as shown in this screenshot (tested on Google Chrome 80.0): https://i.stack.imgur.com/r5Cz0.png Initially, it ...