Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
Add a Line Break In HTML Email

I have made a request form for my work and it working as expected. I have placed some text in the text area as a hide/show for users. On the visual studio code, I see the line breaks fine but when I submit the form and the recipient gets the email all that was in the text area is all in one line instead of line break where I wanted.

Also how to kill the extra white spaces. Also have used this

Is there any fix to this?

I get this in email DC GM Groups Domain Group Access:  All Folders and Drives Required Distribution List:  All Emails

Tried everything I could research but doesn't seem to work

white-space: nowrap;
text-align: left;
width: 650px;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="col-6">
  <!-- style="visibility:hidden;" -->
  <!-- acc means account -->
  <textarea class="textarea" id="acc_GMGroup" name="acc_GMGroup" rows="10">
Domain Group Access:&#13;&#10;&emsp;All Folders and Drives Required&#13;&#10;
Distribution List:&#13;&#10;&emsp;All Emails

                            </textarea>
</div>

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

To answer your first two questions

The easiest way to format like it is in the text area is to put the text between <pre>...</pre> tags

The other thing you could do is use regular expressions to switch from text to html, like

text.replace(/[\n]/g,"<br>");
text.replace(/\s\s+/g,function(part) {
  return part.substring(0,1);
}));
about 4 years ago · Juan Pablo Isaza Report

0

A textarea will render whitespace as it was entered into the element so just format the whitespace by literally adding it.

<div class="col-6">
  <textarea class="textarea" id="acc_GMGroup" name="acc_GMGroup" rows="10">
Domain Group Access:
 All Folders and Drives Required
 
Distribution List:
 All Emails
  </textarea>
</div>

about 4 years ago · Juan Pablo Isaza Report

0

So i was able to do deep research and found you can do this to make it work: just add nl2br

$usersGMGroup = nl2br($_POST["acc_GMGroup"]);

Thank you to all the people that helped to resolve the issue

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!