splitting lengthy words into several lines

Does anyone know how to break words like the examples below using CSS or jQuery?

SAMPLE 1

ConfigTechnologyHormonyAppComponentBackOfficeLaunch

It needs to be broken into

ConfigTechnologyHo
rmonyAppComponentB
ackOfficeLaunch

SAMPLE 2

WorkAppComponentBackOfficeLaunchTechnologyNeteseen

It needs to be broken into

WorkAppComponentBa
ckOfficeLaunchTech
nologyNeteseen

SAMPLE 3

Supplement Hormony based on Continous Integration

It needs to be broken into

Supplement Hormony
based on Continous
Integration

I've attempted using word-break: break-all; but it doesn't seem to be working.

Answer №1

To ensure your text container fits within your layout, it is important to set a specific max-width. Check out the example below:

CSS:

p {
  max-width: 100px;
  word-break: break-all;
}

HTML:

<p>
ConfigTechnologyHormonyAppComponentBackOfficeLaunch
</p>

Answer №2

.container{
  max-width:100px;
  border:thin black solid;
  word-break:break-all;
  height:auto;
  }
<div class="container">Config TechnologyHormonyApp ComponentBackOfficeLaunch</div>

Give this code a try.

Hopefully, you find this information helpful.

PS: Feel free to adjust the max-width value of container based on your specific requirements.

Answer №3

Here is a suggested code snippet for you to try:

.product-name a:before {
    content:"CustomizeYourApp \A ndBoostProductivityWith \A pplicationDevelopment ";
    white-space: pre;
    font-size:18px;
}
.product-name a {
    text-indent:-9999px;
    font-size:0;
    text-decoration: none;
}
<h2 class="product-name"> 
  <a></a>
</h2>

Answer №4

You have the ability to achieve this using JavaScript

const longString = 'SoftwareApplicationDevelopmentProgrammingSkills';
const stringArray = longString.split('');
const rowLength = 15;

let formattedText = '';
for(let j=0; j<stringArray.length;j++) {
   formattedText += stringArray[j];
if (j % rowLength == 0 && j>1) {
    formattedText += '</br>';//or \n\r
    }
}
document.getElementById('formatted-text').innerHTML = formattedText;

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

Tips for customizing the appearance of an HTML dropdown menu

Here is the code snippet: <select name="xyz" id="abc"> <option value="x">10/Page</option> <option value="y">20/Page</option> <option value="z">30/Pa ...

Utilizing an Ajax spinner for numerous inputs within a single form

Currently, I have implemented a spinner that is displayed when an ajax request is triggered using jQuery: $(document).bind("ajaxStart", function() { $('#myloader').show(); }); $(document).bind("ajaxStop", function() { $('#myloader&a ...

Retrieving Data from all Rows in jQuery DataTables

Is there a way to copy all rows in jQuery DataTables into a JavaScript array by clicking the header checkbox? https://i.sstatic.net/57dTB.png I need to locate where jQuery DataTables store the HTML for the remaining page of rows so that I can manipulate ...

A step-by-step guide on adding a table with colored icons (red, green, and blue) to an HTML page using jQuery

I'm working on a project that requires designing an HTML page with three tables containing images, along with a compare button. Initially, only two tables are visible upon page load, but when the user clicks the compare button, the third table should ...

How to utilize Bootstrap 5 flex for aligning text in the center position

Within these specific divs: <div class="col-6 col-md-4 col-lg-3 col-xl-2 my-3"> <a href="#" title="Falazóhabarcs" class="main_category d-flex justify-content-between align-items-center radius p-3&quo ...

Creating your own ListView using the BindingHandler feature in KnockoutJS

Looking to create a custom listView with selectedItem and Itemsource features. Experimenting with a jsFiddle can be found here: http://jsfiddle.net/andersb79/53xRL/1/ Seeking guidance on how best to approach building this, as I have not come across a bin ...

Activating an Ajax-filled dropdown when the previous dropdown remains unchanged but a selection has been made

I am working with three dropdowns: the first one is populated from the server, the second one is filled via ajax based on a change in the first dropdown, and the third one is also filled via ajax based on a change in the second dropdown. Below is the code ...

The enigma of HTML forms never ceases to baffle

Currently, I am enrolled in a Vue.js course and have recently delved into the topic of forms and their management. The concept posed about how the < select > tag operates has left me puzzled. Is it correct to assume that its value corresponds to the ...

Is it possible to shift the div inline-block using the CSS :after selector?

I'm looking to adjust the placement of the disk icon so that it aligns more with the baseline of the text without increasing the vertical space between lines. Below is the CSS code I've worked on so far: .openPage:after { content: ' &a ...

Adjusting Text Color on Buttons

I am looking for a simple button with clear color and black text, but the default button has white text. I need a way to change the text color. Check out my current app <View style={styles.fastlog}> <Button style={styles.bouton} title= "Con ...

Angular: "btn" class vanishes when the button is toggled

I am facing an issue with the button's class change functionality. I am using the [ngClass] directive to switch between Bootstrap classes for the button style. However, when I click the button, the "btn" class seems to disappear from the code. Instead ...

Perform an Ajax request to a C# Controller Function

In my javascript file named "data handling.js" within a folder labeled "JS", you'll find the following piece of code: document.getElementById('submit-new-project').addEventListener("click", function () { var ProjectName = document.getEl ...

Designing a File Export Functionality in MVC3

I am working on a strongly typed View in ASP.NET MVC3 that displays a Model, and I want to implement a feature where the user can download the displayed model as a CSV file. My initial thought is to create a link that points to another action on the contro ...

Prevent links from being clicked multiple times in Rails using Coffeescript

Please make the following link inactive after it has been clicked once <%= link_to "Submit Order", {:action => "charge"}, class: 'btn btn-primary', id: 'confirmButton' %> To permanently deactivate the link, use the code below ...

Executing jQuery function through variable reference

My goal is to modify the jQuery function being used based on the value of a switch statement. In this scenario, I want to select the element and then apply the appropriate jQuery function depending on the 'direction' parameter. $('#'+t ...

Exploring Symfony2 controller integration with Javascript arguments

I am currently working on a project with Symfony2 and I have a question regarding receiving arguments from a template in a controller. My goal is to take the value of the argument and store it in the database. The argument's value will be generated by ...

Experimenting with a function invoked from a jQuery AJAX callback using Jasmine testing framework

Currently, I'm working on a function that utilizes an AJAX call to interact with a service. My main goal is to ensure the displayError function is triggered in case of a failure. The ajaxCall function is set up to accept a URL parameter. When the req ...

What steps can be taken to ensure the random generator continues to function multiple times?

My little generator can choose a random item from an array and show it as text in a div. However, it seems to only work once. I'm looking for a way to make it refresh the text every time you click on it. var items = Array(523,3452,334,31,5346); var r ...

When the text overflows the boundaries of a paragraph in CSS HTML

I am facing an issue with text overflowing in a paragraph <p style="width:200px;">Text goes here</p> As the text in the paragraph increases in width, it does not automatically wrap to a new line, causing it to overflow outside the paragraph ...

The conditional statement for multiplying in JavaScript

I have a JavaScript function that selects a report number based on multiple parameters (2 checkboxes, 3 dropdown fields), and the current implementation involves a complex conditional statement as shown below: switch(ReportNumDrop) { case 0 ...