Roman numerals list with parenthesis mandatory

I am looking to create a CSS style to achieve the following output...

1. What is the current demand?

2. Which segment(s) does it target?

3. With the innovative approach given...

4. Considering the creative solution provided...

...and so forth.

Your suggestions are welcome!

Answer №1

To accomplish this task, utilize the counter-increment property in CSS. Implement it as shown below:

ul{
    counter-reset:item;
    list-style:none;
}
li:before        {
    content: "("counter(item, lower-roman) ")";
    counter-increment: item;
}

For a demonstration, visit http://jsfiddle.net/MEBxA/

This method is effective on Internet Explorer 8 and newer versions.

Answer №2

When looking for unique numbering styles beyond the typical list-style-type, there are two main options:

  1. Remove default numbering with list-style: none and create numbers using counters, generated content, and the :before pseudo-element (like in sandeep’s answer).
  2. Include numbers in the content, possibly generated through server-side techniques. Either remove default numbering for ul or avoid ul altogether by using elements like div or table.

For example, a simple approach would be:

(i) What is the demand?<br>
(ii) For what segment(s)?<br>
…

To easily style the entire list, its items, and the numbers, it's recommended to use more detailed markup such as this:

<div class=ol>
<div class=li><span class=num>(i)</span> What is the demand?</div>
<div class=li><span class=num>(ii)</span> For what segment(s)?</div>
…
</div>

(While using blockquote instead of div as the outermost markup may improve fallback for non-CSS rendering, some may argue it leads to semantically incorrect markup.)

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

Lag experienced in Chrome browser on Mac due to Bootstrap CSS framework

I created a basic HTML and CSS file using Bootstrap that runs smoothly on my work computer with Chrome version 27.0.1453.110. However, when I attempt to open the file in Chrome on my personal Mac (unknown Chrome version), it loads very slowly and experienc ...

Background image that covers the entire screen, div elements that scroll on top of the landing screen initially

As a beginner in the world of coding, I apologize for any simple errors in my attempt. Despite researching this issue, I have not been able to find a precise solution that fits my needs. My goal is to create a full-screen background for the landing page. ...

What is the best way to eliminate choices from several dropdown lists?

Is there a way to remove a choice made in one dropdown menu from another? I'm not sure if it can be done with dropdown menus or if I need to use datalist or something else. For example, let's say I have 6 dropdown menus like this: dropdown menu& ...

Retrieve the URL from the onclick property of an anchor element using Python

Struggling to extract a URL from an onclick attribute in a tag using Selenium with Python. The URL is located within a JavaScript function, and despite trying multiple techniques, the solution remains elusive. Executing the onclick function through the exe ...

Examining the performance of the user interface on a web application

In my current project, I am working on optimizing the user interface of a web application used exclusively by company staff. Since the server-client connection speed is significantly faster within our internal network compared to external internet usage, m ...

The overflow property's auto and scroll functions are not functioning properly

I stumbled upon this amazing theme that has captured my heart. Start Bootstrap template I am planning to use this theme for my portfolio website, but I need to make a few modifications to achieve my desired look. When you click on any of the thumbnails, ...

How to create nested nav menus that are optimized for touch-screen devices?

When it comes to creating responsive websites, one challenge I frequently encounter is designing a multi-level nav menu that functions effectively for touch devices. Many plugins and methods exist, but most fall short because they do not allow a second-l ...

What is the reason that the attr function fails to function in this particular scenario?

I want to implement a functionality where clicking on an input field clears its value, but I can't seem to make it work. Here is the HTML code: <input id='input' type="text" name="phppostvar" value="clear this"></input> This i ...

What's Going on with My Angular Dropdown Menu?

Snippet of HTML code: <li class="nav-item dropdown pe-3"> <a class="nav-link nav-profile d-flex align-items-center pe-0" (click)="toggleProfileMenu()"> <img src="assets/img/profile-img.jpg" alt=& ...

The scroll bar is visible on the scroll box, but unfortunately it is not functional in Internet Explorer 8

http://example.com/code <div style="width:625px;height:220px;overflow-y:hidden;overflow-x:scroll;z-index:10;"> <table width="1000" height="114" border="1"> <tr> <td width ...

Can you explain the function of the forward slash in the HTML img tag?

Currently, I am in the process of learning html/css by following the tutorial provided by W3Schools.com. The part of the code that is causing me some difficulty can be found at http://www.w3schools.com/css/tryit.asp?filename=trycss_vertical-align Specific ...

Limit the character count in a textarea

My goal is to control the number of characters that can be entered into a textarea. While I am aware that I could simply use a substring to limit the characters, I prefer to visually inform the user when their text has reached the maximum length. The maxl ...

The number of columns in the table do not match

Observing the table below, it appears that although I have used colspan="4" for two td elements, they are not equal in width. The first column seems to be wider than the second. What might be causing this discrepancy? <table border="0" cellpadd ...

Stop horizontal scrolling caused by 100vw

When an element is set to width: 100vw; and a vertical scrollbar appears, the width of the element will include the viewport width plus the width of the scrollbar. Is there a way to prevent this behavior? Is it possible to avoid this without disabling ho ...

PHP form auto-submitting on page load/refresh

I'm struggling with my PHP form as it keeps submitting every time the page is loaded or refreshed. Ideally, I want it to only submit when the submit button is clicked. Since I'm new to PHP, I would really appreciate some guidance on how to achiev ...

Changing the value of a user object's variable in Django

I have been working on implementing a feature that allows users to edit their personal information in a Django project using Django forms. However, after entering new values in the form and hitting enter, the user is redirected back to the main profile pag ...

Having difficulty adjusting the appearance of the navigation bar dropdown

I'm currently facing an issue with changing the background color of my nav-bar dropdown to black, as well as adjusting the width of the dropdown options to fit the screen. Despite trying the code provided below, I am unable to change the dropdown bac ...

Transform pixel padding into percentage ratios

I've been searching through various discussions to find a solution, but none of them seem to fit my particular scenario. My issue involves a hyperlink with absolute positioning inside a div with relative positioning. The padding and margins are curre ...

The font size escalates following the activation of a Java alert box on an ASPX webpage

Recently, I came across an interesting solution to a problem with a PHP application. It was discovered that placing the Java Script in the body section resolved the issue where CSS file attributes were being ignored when clicking the Alert box. In my code ...

What steps should be taken to correct the alignment of the text in the comment?

I'm trying to achieve a layout where the comment's text appears underneath the user image, similar to this example: https://i.sstatic.net/8unS5UTK.png However, my current output shows the comment's text next to the user image instead of bel ...