CSS Property for Managing Space: White Space

Here is a td block that displays data in this format:

My name is Ramya and 
I love football.
I work for ABC Company.

<td style="text-align: left;overflow-wrap:break-word;width:50px;">

@Html.DisplayFor(modelItem => item.Text)

</td>

I am looking to modify the display of my td like so:

My name is Ramya and 
     I love football.
     I work for ABC 
     Company.

Which CSS property should I apply to accomplish this? Each wrapped line needs some whitespace.

Answer №1

[from comments] My goal is to adjust the line breaks based on the width of the table cell. When the content wraps and exceeds the cell width, I want it to have some white space before continuing onto the next line.

Is this what you had in mind?

td { width:100px; overflow-wrap:break-word; padding-left:20px;
     text-indent:-20px; text-align:left; background:#fcc; }
<table>
  <tr>
    <td>
      Hi there, my name is Emily and I enjoy hiking in the great outdoors.
    </td>
  </tr>
</table>

padding-left:20px; adds padding to all the content in the cell, while text-indent:-20px; repositions the first line to the left by the same amount.

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 options exist for the format field in a font-face src declaration?

How can I determine when and how to use different font formats, and are they always necessary? Various websites provide examples like the ones below, with different arrangements: @font-face { font-family: 'Example'; src: url('Example.eo ...

The content within an inline-block element exceeds the boundaries of its parent <pre> tag and causes overflow

I'm currently exploring ways to incorporate line numbers into text within a <pre> tag, all while maintaining the ability for the text to wrap. This presents some unique challenges: Adding line numbers in a separate column of a table is not an ...

Tips for extracting innerHTML or sub-string from all elements that have a specific class name using JavaScript

When it comes to shortening the innerHTML of an element by its Id, I have found success using either slice or substring. While I'm not entirely clear on the differences between the two methods, both accomplish what I need them to do. The code snippet ...

Create a dynamic calendar by integrating dates with Javascript and an HTML table

Recently, I decided to delve into web design again and embark on a challenging project for my father's baseball business. The main task at hand is creating a detailed calendar using HTML tables. After spending a considerable amount of time perfecting ...

To add a code snippet to the right side of a paragraph using CSS, place it at the end of the

Is there a way to insert code at the end of each paragraph and have it aligned to the right on the same line as the last sentence? Update: I initially tried using float:right, but encountered an issue with vertically aligning the code with the last line ...

Fixed Sidebar Position Changes when Bootstrap Modal Closes

We are facing a peculiar issue in our React application involving a sidebar and a bootstrap modal. The problem arises when we click the "X" button in the modal, causing the sidebar to momentarily drop down the page before the modal closes. This strange be ...

"Utilizing the appendTo attribute in primeNG within a ContextMenu component - A step-by-step guide

Currently, I am attempting to utilize the appendTo attribute within the ContextMenu component. My intention is to associate this behavior with a specific element, such as a div. ...

How can I delete the black background from the ion-tab-bar in Ionic 7?

In my current project using Ionic 7, I have a navigation guide set up with 4 tabs. I am trying to customize the styling of these ion tabs by adding some custom CSS. The issue I'm facing is that despite my attempts to make the background transparent, ...

Broken styles when using Material UI with babel and the 'with styles' feature

We've implemented babel and lerna to maintain specific elements of our react web app separately. While the setup has been effective thus far, we're encountering styling issues when generating the static build. The main project is not processed t ...

The height of EasyAutoComplete is restricted by the designated div height

I am experiencing an issue with my EasyAutoComplete feature that displays City & PostalCode information. The problem lies in the height of the div containing the input field, which limits the visibility of the EasyAutocomplete window. Only the first elemen ...

Help! My HTML/CSS (Bootstrap) text won't center properly. Can anyone assist me?

My text doesn't seem to be centered on the page, despite using the "text-center" class for the caption text. What am I missing here? <div class="text-center"> <h1>Evelyn Lauder </h1> <h5 class="font-italic"> 1936-2011</ ...

Incorporating Unique Typography with Typekit/Adobe Fonts in Tiny MCE editor within a React

I'm currently working on integrating a custom Adobe Typekit font into a TinyMCE React component to customize the text styling within the editor. Here is the setup I have: <Editor init={{ allow_html_in_named_anchor: false, ...

Dynamic Data Binding in Ionic 2

One challenge I am facing is with creating my own info window for a Google Maps marker. Whenever I click on the marker, a div is displayed but the information inside the div does not get updated. It seems like the event.title remains unchanged from its old ...

Tips for eliminating the entire link from the footer section

Whenever a link is hovered over, a white box displaying the full URL appears at the bottom left of the browser. Is there a way to remove this feature from my website? I appreciate any assistance with this issue. Thank you! ...

CSS: elements that are only visible when positioned above specific elements

Can we create an element that is only visible above specific other elements? For instance, in the following code snippet, I want the .reflection element to be visible only above the .reflective elements (located at the top and bottom) and not visible on t ...

Guide on setting up and duplicating a template in Vue.js

Allow the user to create multiple person entries by clicking a button with the method "useIt()". A template has been created for this purpose. When the button is clicked, the template should be duplicated and added to the container div. This functionality ...

Transform JSON data into an HTML layout

I'm looking to design a structure that showcases JSON information using HTML div elements. For example, utilizing the h4 tag for headers, p tag for text descriptions, and img tag for images. Can anyone provide guidance on the most efficient approach ...

Is there a way to create a validation code in PYTHON/Flask for users based on the URL they enter?

Seeking guidance on how to approach a specific task with Python and Flask. The task involves: Checking if a URL is valid If valid, returning a list of all links on that page and its sub-pages I use Sublime editor running under Windows Powershell. Curre ...

Changing the color of an element on click using jQuery's .css() method,

There is a table and I am using fadeToggle on the list to hide and show the table. The background of the list is green color, but I want to change the list color when hiding the table and revert it back to green when clicking to show the table. Unfortunate ...

Unspecified origins of Js in Chrome Extension

console.log(chrome.runtime.sendMessage({from:"script2",message:"hello!"})); However, attempting to send the message from a background script to a content script is proving to be unsuccessful. https://i.stack.imgur.com/ERgJB.png ...