The text of a list item wraps underneath the marker before filling the rest of the available space

I'm facing an issue where text in a list item is being pushed to the line below the bullet point. I want the text to fill the first line with the bullet before wrapping to the next line without using list-style-position: outside. Here is my CSS:

.list-item {
  display: list-item;
  background-color: gray;
  width: 100px;
  list-style-position: inside;
  overflow-wrap: break-word;
}

Here is how I am trying to apply it:

<div class="list-item">
  testlonglistitemtext
</div>

Answer №1

If you want to handle long text in CSS, consider using word-break: break-all instead of overflow-wrap: break-word:

.text-container {
  display: block;
  width: 200px;
  background-color: lightgray;
  word-break: break-all;
}
<div class="text-container">
  ThisIsALongTextThatShouldBreakWithWordBreak
</div>

The differences between these two properties are essential.

About break-word:

Unlike ... overflow-wrap: break-word ..., word-break: break-all will cause a line break exactly where needed to prevent overflow (even if it means breaking within a word).

Regarding overflow-wrap:

Compared to word-break, overflow-wrap will only break if fitting an entire word without overflowing is impossible.

To summarize, the difference lies in how they deal with overflowing text: overflow-wrap: break-word attempts to keep the word intact as much as possible before breaking, while word-break: break-all breaks whenever necessary to fit the content box.

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

Increase the number of columns in ion-grid to a maximum of 24 columns by customizing the ion-grid columns

Can anyone assist me in achieving an ion-grid with 24 columns? I was researching the Ionic page (https://ionicframework.com/docs/layout/grid) and came across the property "--ion-grid-columns" under the "Number of columns" section. Unfortunately, there was ...

Is there a way to identify the specific Struts action being rendered in my JSP file?

One thing I am struggling with is creating a menu that highlights the current page when navigating through my site. For example, if I am on Page 1, I want the "Page 1" link in the menu to stand out. I have been attempting different methods found on Stack O ...

The output display is not visible

I am currently working on a tutorial to showcase contact details on my webpage. However, I am facing an issue where the code is not displaying the first and last name as expected. Below is the code snippet for reference. Snippet from index.html <!DOCT ...

What do the transition props for Material-UI (MUI) entail

Can you provide more information on React MUI transition props besides "transform"? transition: theme.transitions.create(["color", "transform"], { duration: theme.transitions.duration.shortest, }) I have been looking through the MUI documentation but I am ...

Parent style CSS taking precedence over child style due to conflicting rules

Feeling a bit puzzled by another answer on SO... I have two tables, with one nested inside the other. (a table within a table) <table class="master"> <tr> <td>ID</td><td>Name</td><td>Information</td> ...

displaying data with the use of Ajax in laravel

Querying data from the 'Company' table in the database and receiving it in JSON format, I am now looking to present it in a Data Table. Controller public function fetch(Request $request){ $table = \DB::table('company')-&g ...

Adjust the background hue of the Row in the Table

Is there a way to update the background color of a Table Row? I attempted using "BackgroundColor" but didn't see any changes Any suggestions on how to fix this issue? <TableRow style={{ backgroundColor: "#FF0000" }}> <TableCell& ...

Exploring the world of child theme customization in WordPress

I am looking to make some modifications to my website. Working with a child theme, I have plans to adjust the CSS and make some structural changes. Modifying the CSS seems pretty straightforward as I just need to reference the classes or IDs and input new ...

Separate the content of a textarea using jQuery into two separate textareas based on a specified line number

Is it possible to use jQuery to split the content of a textarea into two separate textareas at a specific line number? After searching on Google, I couldn't find any information. Given jQuery's power, I would have assumed this task could be achi ...

Guide to centering a button on an image using bootstrap 4

I'm having trouble getting three buttons to align vertically in the center of an image using Bootstrap 4. I've tried using position:relative on the image and position:absolute on the buttons, but it's not working as expected. <div class= ...

Setting a border on a specific column in ag-grid is a simple task that can help you customize

I have a table where the first set of columns differs from the rest. I am looking to emphasize this distinction by adding a vertical border on the right side of the specific column to highlight it both in the header and rows. Our setup includes using the ...

Bar graph constructed using a pair of div elements

I extracted two values from an array: $target = $data->data[2][32][3]; For this particular example, $target = 9.83%. $clicks = $data->data[1][32][3]; And in this case, $clicks = 7.15%. I have created a bar-like chart using three main div elements ...

Is it possible to make a DIV adjust its size automatically when the browser is resized?

Greetings! Here's my initial query, with more to follow. I've encountered an issue where a div on my page is set to 70% of the screen, but upon resizing the browser to a smaller size, some content within the div extends past the bottom of the pa ...

Navigate to the top of a Bootstrap accordion when it is expanded

Recently, I've been working on a small blog and I want to make consecutive blog posts accessible from within an accordion. This will allow users to easily skim through post titles, select the one they find interesting, read it, and seamlessly go back ...

Incorporate a share (contact) feature for WhatsApp and various messaging platforms on your website

Is there a way to include a share button on my website's page? I found that we can add a send SMS feature to mobile HTML pages using the following code: <a href="sms:?body=...">title</a> How can we implement this code for sharin ...

AngularJs FileList Drag and Drop Feature

Being brand new to front-end development, I decided it would be a fun challenge to implement drag and drop functionality on an existing upload page. However, as I began integrating ng-flow (a directive that helps with drag and drop), I encountered difficul ...

How can I adjust height without affecting weight in CSS using curly brackets?

Can CSS be used to specifically adjust the height of a curly bracket without changing its thickness? I have been attempting to modify the height of a curly bracket dynamically by adjusting the font-size, but this also alters the weight. Is there a workar ...

Combining Cells in HTML Tables

Currently, I am attempting to create a table using HTML, but I have encountered a problem that I am unsure how to solve: Is there a way to convert a cell located below or next to another cell that contains lengthy vertical text into a smaller square forma ...

What is the reason behind the jQuery .after() method inserting a row that is cramming itself into one cell?

I'm attempting to dynamically add cells to the right side of a table using jQuery when a row is clicked. I have successfully implemented inserting a new row on click, which also toggles its visibility with CSS. However, I am encountering an issue whe ...

When there is an absence of data, the jQuery datatable mysteriously van

I have encountered an issue in my Django app where a datatable used in the template disappears if there is missing data in any column or row. The problem occurs when trying to download the data in CSV, Excel, PDF, or copy format. Here is the HTML code snip ...