Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

296
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda