CSS, The text is spilling over outside the boundaries of the table cell

I am currently working on a Virtual Machine and unfortunately cannot copy the code. However, I will provide screenshots instead. The problem seems trivial, but I am struggling to solve it. Can someone please offer some suggestions?

Here is the table code:

And here is the CSS code and view of the website:

In general, as seen in the second link provided, there is text within a row that refuses to wrap. Instead, it extends beyond the boundaries of the table column. Any help would be greatly appreciated.

Answer №1

Example for Understanding

Imagine a scenario where you have a basic two-row table with two cells in each row:

<table>
    <tr>
        <th>Primary</th>
        <th>Secondary</th>
    </tr>
    <tr>
        <td>Small font</td>
        <td>ExtremelyLongNonHyphenatedTextLineThatShouldWrap</td>
    </tr>    
</table>

One of the cells contains a lengthy word without spaces or hyphens, making it challenging for it to break.

Below is some CSS code:

table {
    border: 1px solid lightgray;
}
table th {
    background-color: silver;
    text-align: center;
    padding: 10px;
}
table td {
    width: 200px;
    border: 1px dotted silver;
    word-break: break-all;
}

The cells are set at a fixed width of 200px. However, due to the extended non-breaking word, two things may occur.

(1) The table could expand the column width to fit the lengthy text.
(2) The text might overflow from a cell based on other factors like having a fixed layout with a specified table width.

By applying word-break: break-all to the table cells, the text will wrap while maintaining the predefined widths of the table columns.

Check out the demo here:

Additional Information

To delve deeper into the CSS3 word-break property, visit:

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

What is the best way to distinguish automatically generated links using JavaScript?

(Hello Dr. Nick) JavaScript is a new area for me and I am currently working on creating a website using asp.net EF JavaScript and other tools... I have created links based on the information stored in my database, and I want the name of the link to appea ...

Performance issues with the iOs CSS keyboard appearance are causing delays in

Recently updated my application to be mobile-friendly. I've noticed that at times, the keyboard seems to have a slight delay in appearing when I tap on an input field. I have around 20 inputs on a single page. I conducted a test with the same number ...

How you can incorporate an icon in between menu items using Bootstrap 4

As a novice web developer, I am currently utilizing Bootstrap 4 in my project. Here is the code snippet I have created: .footer-menu a{ color: #2D2D2D; font-size: 1em; } .copyright{ color: #D1D1D1; font-size: 0.9em; } <footer> ...

I am interested in utilizing Google Apps Script (GAS) to store images in GoogleDrive and automatically populate the corresponding URL in a

Currently, I am utilizing GoogleAppsScript to develop a form for submitting names and images. The idea is to store the submitted name and image in GoogleSpreadSheet while also storing the image in GoogleDrive along with its destination URL. The process inv ...

Attempting to devise a jQuery algorithm sorting method

To enhance the answer provided in this post: How to stack divs without spaces and maintain order on smaller screens using Bootstrap I've been exploring ways to develop a jQuery script that dynamically adjusts the margin-top of div elements based on t ...

Strange issue with Firefox when utilizing disabled attribute as "disabled"

I found a curious bug in Firefox: Check out (unfortunately not reproducible in jsfiddle) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> < ...

Exploring the document body with jquery

In my homescreen.jsp, I have a link that opens an iFrame when clicked. My goal is to hide the vertical scrollbar of homescreen.jsp when the iFrame is open. Using jQuery, I attempted to access the body of homescreen.jsp and was successful. However, I encou ...

Do you require assistance with creating an image slideshow?

My first day working with HTML was a success as I successfully built a navigation bar that looks pretty cool. Take a look at it here. Next on my list is to incorporate a slideshow into my site, possibly using JavaScript or jQuery plugins. I'm aiming ...

What seems to be the issue with my code for Javascript Math functions?

Welcome to the number game slider! If you roll above 50, you will get double the amount bet. Use the slider to choose your desired betting amount. Issue 1: After a win, the score does not update correctly. Instead of showing increments of 5, it displays s ...

What's the most effective way to constrain focus within a Modal Component?

Currently working on a library of components in Angular 8, one of the components being a modal that displays a window dialog. The goal is to prevent focus from moving outside the modal so that users can only focus on the buttons inside by using the Tab but ...

Run a function upon clicking a button in JavaScript

Could someone please help me figure out what I am doing incorrectly in the code below? I am attempting to trigger a function when a button is clicked. The HTML: <button id="btn1">Press me!</button> <input type="button" id="btn2" value="Pr ...

Conceal elements with a single click of a button

How can I use jQuery to hide all li elements with an aria-label containing the word COMPANY when the Search from documents button is clicked? Here is the HTML code: <ul class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" id="ui-id-1" t ...

Angular 2's SVG creations do not resize properly

It is a common knowledge that an svg element with the attribute viewbox should automatically scale to fit the sizes specified in the styles. For instance, let's consider a 200*200 circle placed inside a 100*100 div. Prior to that, we need to ensure t ...

Generate a new tree structure using the identifiers of list items within an unorganized list

Attempting to convert the id's of li's in a nested unordered list into valid JSON. For example, consider the following list. To be clear, the goal is not to create the UL list itself, but rather the JSON from the li id's <ul class="lis ...

Arranging numerous Text elements within a solitary Drag and Drop container with the z-index property

I am facing a challenge with stacking twelve arguments in no particular order on a drag and drop element. The texts overlap each other, making it difficult for the end user to see them clearly when dragging and dropping. Is there a way to stack texts using ...

Using Angular to convert JSON data to PDF format and send it to the printer

Currently, I am retrieving JSON data from an API and now need to convert this data into a PDF format for printing. I am encountering an issue where the CSS styling for page breaks is not rendering properly within my Angular component. When I test the same ...

How is it possible that I am still receiving spam emails even though I have already implemented reCaptcha

I recently integrated Google reCAPTCHA v3 into my HTML form to combat spam emails, but I'm still receiving unwanted messages. What steps can I take to further prevent spam without relying on PHP code and using only JavaScript scripts? Currently, my c ...

"Experiencing a callstack overflow due to multiple carousels on one page using Jquery or Vanilla

Currently, I am working on implementing a Jquery infinite autoplay multiple carousel. What I have done is created two separate carousel blocks on the same page within the body section. <div class="rotating_block"> <div class="bl ...

Transformation in CSS3 is not supported for DIV elements

Seeking help to implement a "Flip card" effect on div elements (cards). I have applied the code below, but encountering an issue. The goal is to flip the "Card" Div element by utilizing the JavaScript function "OpenCard()" provided below. EDIT 1: Added js ...

Code Not Functioning on Website Despite Working in Console

I've developed a jQuery script that eliminates any delivery methods containing the phrase "Royal Mail" if certain products are present in the user's cart. The script functions flawlessly when executed in Google Chrome Console but fails to work wh ...