Is it possible to include text in my numbered list?

My itinerary consists of the following ordered list:

  1. place1
  2. place2
  3. place3

Since this is for a trip plan, I would like it to appear as follows:

Day 1: place1

Day 2: place2

Day 3: place3

I could manually type it out as plain text, but I am looking for a way to present it as a formatted list. Is this doable?

Answer №1

ol {
  position:relative;
  padding-left: 50px;
}
ol li:before {
  content:"Day";
  position:absolute;
  left:0;
}
<ol>
  <li>content1</li>
  <li>content2</li>
  <li>content3</li>
</ol>

This is an example of CSS styling for ordered lists with custom numbering.

Answer №2

If you want to achieve this without manually positioning the list items, you can reset the list style and utilize pseudo elements for styling:

  1. Begin by resetting the list style with list-style-type:none and padding:0

  2. Next, use a counter to generate the desired list numbering

Check out the demo below:

ul {
  list-style-type: none;
  padding: 0;
  counter-reset: list;
}
ul li:before {
  content: 'Day ' counter(list) ' : ';
  counter-increment: list;
}
<ul>
  <li>content1</li>
  <li>content2</li>
  <li>content3</li>
</ul>

Answer №3

To accomplish this task, one can create an unordered list and set the list-style of the ul to none in css. Next, utilize the css before pseudo-element for each li element using selectors like li:nth-of-type(1) with content "Day 1:" and li:nth-of-type(2) with content "Day 2:", then adjust their positioning accordingly.

Answer №4

const activities = {}

//insert into the activities list
activities.Day1 = 'Exploring new places';
activities.Day2 = 'Relaxing by the beach';
//continue adding more activities

//display the list of activities
console.log(activities);

//assign a tag and data to it
function insertIntoHTML(tag, content) {
   var element = document.getElementById(tag);
   element.replaceWith(content);
};

// add activity for Day 1
insertIntoHTML('day1', activities.Day1)

No specific language mentioned so assuming javascript. Now in html:

<!-- using <li></li> will add bullet points -->
<ul id="day1"></ul>

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

Trigger an onchange event to retrieve the object with React autocomplete

When the onchange event occurs, I am expecting to retrieve a vehicle object. However, all I am getting is a vehicle number displayed as a dropdown value. Even when I try to pass an item to get the vehicle object, I still end up with just the vehicle number ...

Displaying both the label and store ID in Jquery autocomplete data

I have implemented jQuery UI autocomplete with an AJAX source on my input field. The goal is to display the label to the user, while storing the corresponding ID in the value behind the scenes without using a hidden field. I aim to achieve this by storing ...

What are some techniques for concealing the source of an iframe or embed tag with JavaScript, jQuery, or PHP?

Is there a way to conceal the src URL for a PDF file within an iframe or embed? I have tried various methods mentioned before, but none seem to be effective. <?php $url = $_GET['url']; ?> <embed id="renderedPrint" style=&q ...

Steps for creating a modal in Angular without using the ui-bootstrap library:

I've been attempting to display the modal, but haven't been able to succeed even after several tries. Below is the code for the modal: <!-- Login modal --> <div class="modal fade" id="login_2" tabindex="-1" role="dialog" aria-labell ...

Firefox fails to render SVG animation

Currently, I'm attempting to incorporate this unique animation into my website: http://codepen.io/dbj/full/epXEyd I've implemented the following JavaScript code in order to achieve the desired effect: var tl = new TimelineLite; tl.staggerFromTo ...

Tips for preventing <v-layouts> from impacting one another

I'm currently working on a dynamic link box for a homepage website, which can be viewed at . Inside this link box, I have included a button that allows the creation of buttons that function as links. Interestingly, the layouts of both the options but ...

Displaying a sneak peek of the information along with a "See More" button beneath the title in React

My goal is to create a section header followed by preview content that defaults to showing only the first few lines. The text would then fade out, with an option to expand on click labeled "Show More." This functionality is similar to how Reddit displays p ...

Discovering the Xpath for a checkbox within a <div><input> combo using Selenium

Is there a way to successfully click on the checkbox with the provided code? I've attempted using the xpaths below, however, they are unable to locate the checkbox and do not display any errors in the console. driver.findElement(By.xpath("//*[@id=&ap ...

Exploring the incorporation of various local fonts in NextJs version 13

Having trouble adding multiple local fonts to nextjs 13. According to the instructions in the documentation, you should follow these steps for a single file. I attempted to import two files like this: import '@/styles/globals.css'; import localF ...

What is the reason for the undefined output of this verified JSON Web Token (JWT)?

I've been working on decoding a JWT id_token using the libraries jwks-rsa and jsonwebtoken, however, the result keeps coming back as undefined. I understand that this issue is related to callbacks and the need to wait for a response from the getKey f ...

how to assign a value to a field automatically in PHP

Is it possible to send values such as name, email, and contact number from one URL like to another URL at ? I would like these values to be automatically displayed on the form of the target URL (http://www.otherurl.com/test.php). I do not have access to ...

Modify the bootstrap dropdown background to display only an image

I am looking to make the image in a dropdown/dropup menu fill the entire background of the dropdown. Currently, there is still white space visible around the image. How can I ensure that the dropdown shows only the image and includes a scroll wheel? Addit ...

What is the best way to filter intricate JSON based on a condition nested within the JSON

Managing a collection of complex objects that require filtering based on multiple conditions var myList= [ { "UserId": 1, "UserDetails": { "Department": [ { "Name": "dept1" ...

Is it feasible to alter the value by selecting an option from a dropdown menu using Python and Selenium?

Using python selenium for searches on a specific website, I encountered an issue with selecting sections through a dropdown menu. The site's search dialogue offers the choice of searching all sections or a particular section. To pick a section, a sepa ...

Tips for resizing a responsive website

Is it strange to consider scaling down a fully responsive website? Our client insists that every website, including his other ones, should have a max-width of 980px like his main site. So, if the screen size exceeds 980px, how can I scale down the website ...

What is the best method to transfer an array as a parameter from an Ipython notebook to an HTML file that includes specific javascript functions?

I have a unique HTML file named "file.html" that includes a distinctive JavaScript function described below: The Unique file.html <html> <head> </head> <script> function customFunction() { perform an action using ...

Angular's two-way binding feature allows the use of a variable as a string without directly assigning it to

Sample HTML code: <div tile-component included-svg='::installController.installUpdatesSvg'></div> Install controller: **A scope variable named 'installUpdatesSvg' is defined** this.installUpdateSvg = 'xyzSvg'; ...

"Transferring data between PHP and JavaScript has been proving to be erratic and

My PHP code contains values with 2 digits like $var1 = 16; $var2 = 24; $var3 = 31; However, when I use those values and insert them into my JavaScript code like this: var var1 = <?php echo $var1; ?> var var2 = <?php echo $var2; ?> var va ...

Expanding parent nodes in Jstree to load child nodes dynamically (json)

I am trying to optimize the performance by loading the child nodes of a parent node only after clicking on that specific parent node. It is important because there are many child nodes, so this method helps in keeping the performance high. Currently, I ha ...

The multi-level dropdown feature in the BootStrap-4 navbar extends off the screen when the dropdown menu is opened

I have been struggling to make this work. I used BS4 for responsiveness, and my navigation items are aligned to the right in the navbar. Despite trying various methods to position the submenu on the left of the parent menu, I still can't get it to dis ...