A paragraph styled with line numbers using CSS

I struggle with writing long, never-ending paragraphs and need a way to visually break them up by adding line numbers next to each paragraph. While I'd prefer a solution using only CSS for simplicity's sake, JavaScript works too since this is just for personal use. Unfortunately, I can't wrap each line in its own tag because the document is constantly changing. If possible, it would be great if every 5th line could be numbered as well. I hope this explanation makes sense; let me know if you need further clarification.

(By the way, how long do you think a paragraph should be before it becomes too lengthy?)

EDIT: After receiving some feedback and realizing my previous message was confusing, allow me to try again. Imagine I have two paragraphs - one that spans ten lines of text and another that is only three lines. For the first paragraph, I'd like each line to be numbered from 1 to 10, and for the second paragraph, I want the numbering to go from 1 to 3. Does that make more sense now?

Answer №1

Uncertain about what specifically you are seeking

If your goal is to add numbers to p tags using css, you can achieve it with css-counters

Take a look at this code snippet

.container {
  counter-reset: pcount;
}
p::before {
  content: counter(pcount) "):";
  counter-increment: pcount;
}
<div class="container">
  <p>This is p</p>
  <p>This is p</p>
  <p>This is p</p>
  <p>This is p >This is p >This is p >This is p >This is p >This is p >This is p >This is p >This is p</p>
  <p>This is p</p>
</div>

Hope this information proves helpful

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

flexbox: Two vertical icons tightly aligned without any space

Hey everyone, I've been working on this layout: https://i.sstatic.net/4Aye0.png Here's what I tried so far: Resetting padding and margin in the <a href> and in the <img src...> HTML container <div> <div className="pe ...

Is it possible to use an angular expression as the ng-click function?

I have been searching everywhere for the answer to this question. Within my code, there is an angular object called column.addOnParams. This object includes a child element named rowClick, which can be accessed using column.addOnParams.rowClick. The val ...

"Troubleshooting a callback problem in jQuery involving JavaScript and AJAX

UPDATE3 and FINAL: The problem has been resolved with the help of Evan and meder! UPDATE2: To clarify, I need the existing function updateFilters(a,b) to be called, not created. My apologies for any confusion. The issue with the code below is that udpate ...

Stopping the timer with clearInterval isn't functioning as expected

I posted my work online here: Instructions on how to reproduce: Click on a green pin on the map to select a station Fill in the fields for name and last name Sign on the canvas A timer should start counting down from 20 minutes If you click on the ...

The mobile responsive view in Chrome DevTools is displaying incorrect dimensions

Seeking some clarification on an issue I encountered: I recently created a simple webpage and attempted to make an element full width using width: 100vw. However, I observed that on screens smaller than around 300px, the element appeared smaller and not t ...

The value stored in $_POST['valuename'] is not being retrieved

Having recently delved into ajax, I am encountering some difficulties in making it function properly. The objective of the code is to send two variables from JavaScript to PHP and then simply echo them back as a string. However, instead of receiving the e ...

The Bootstrap navigation bar is refusing to collapse

Whenever I resize the screen, the navbar items do not collapse into the toggle menu, instead, they are just stacked below the navbar brand. Any thoughts on why this might be happening? <nav class="navbar navbar-light navbar-expand-md"> ...

Organizing an angular expansion panel

I am currently dealing with an expansion panel that has a lot of content. The layout is quite messy and chaotic, as seen here: https://ibb.co/Y3z9gdf It doesn't look very appealing, so I'm wondering if there is a way to organize it better or ma ...

Horizontal representation of data utilizing PHP and MySQL

Hey there, I'm trying to showcase data from a mysql table in an HTML table horizontally. The code I've got below is almost perfect, except it's skipping the first record (starting at the second) in my database. My gut says it's somethin ...

Verifying the Redux saga test plan's functionality by testing a reducer with a specific state branch

I'm facing some challenges in properly testing my saga. The issue arises because when the saga is running, the reducer is mounted at state: {...initialState}, while my saga select effects expect the reducer to be mounted at state: {authentication: {.. ...

How can we show pictures when a user clicks?

After creating a model for displaying images in a modal when clicked by the user, I encountered an issue. Whenever I try to access the images from the gallery within the modal content, it only displays a blank popup. I want the pictures from the image gall ...

Tips for transferring values from two separate select tags for processing via Ajax and jQuery

HTML Code: <select id="sel"> <option value="dog">dog</option> <option value="cat">cat</option> </select> <select id="sel2"> <option value="chocolate">chocolate</option> <option valu ...

Facing issues with Typescript imports for validatorjs?

Utilizing TypeScript with validator JS and encountering dependency issues: "dependencies": { "@types/validator": "^12.0.1", "validator": "^12.2.0" } Attempting to import isDividibleBy yields an error: import { isDivisibleBy } from "validato ...

Run several asynchronous HTTP requests in the background within a Chrome extension

I am facing a situation where I need to make multiple ajax requests through a Chrome extension and display the successful results in the popup HTML of the extension. I have created an array of URLs and loop through them to perform the ajax requests. Every ...

Guide to making a dynamic image map with interactive links using HTML and CSS

Seeking advice on how to create clickable areas within an image that lead to different pages on my website. Image maps seem like a good solution, but the issue is that they require specific coordinates which may not work well for responsiveness. I was hop ...

In React's contextApi, the this.context object is constantly devoid of any values

sample.js export default class SampleComponent extends React.Component { static contextType= AppProvider; componentDidMount() { console.log('sample',this.context); } render() { return ( <AppConsumer> ...

I'm confused why this particular method within a class is not being inherited by the next class. Rather than seeing the expected extension, I am presented with - [Function (

Working fine with the Person class, the register() function displays the correct return statement when logged in the console. However, upon extending it to the Employee class, instead of the expected return statement, the console logs show [Function (anon ...

Incorporate the <li> components into a search bar and ensure that the parent div element does not experience overflowing

Is it possible to have a user add entries to a search bar without them overflowing the parent div container with the class kitchen? I am looking for a way to limit the number of li elements that can be added to prevent overflow, and I am unsure of what lan ...

"multer's single file upload functionality is not functioning properly, but the array upload

Currently, I am facing an issue while using react js to upload a single file. Interestingly, the multer.single() method seems to fail, whereas the multer.array() method works perfectly fine. What could be causing this problem? //Node.js const upload = mult ...

How can I use Beautiful Soup to change the value of a dropdown button to match the selected dropdown

Is there a way to have my BS4 dropdown menu display the selected value in the dropdown toggle button, specifically .dropdown-toggle? A similar question was asked before here, but it pertains to an older version (BS3 Framework) and does not address using t ...