When I create a language string with multiple HTML elements Joomla! automatically inserts \n between them.

This shows up as a literal \n in the string.

Does anyone know why and how to overcome this issue?

I insert

<h2>This is a heading</h2>
<p>This is some body text</p>

I see

<h2>This is a heading</h2>
<p>This is some body text</p>

If I add the \n then I see \\n in the output

  • 1
    Can you clarify whether it's /n or \n?
    – Sharky
    Commented Jan 11, 2019 at 17:14
  • Good point, yes it's \n I have updated the question
    – Eoin
    Commented Jan 11, 2019 at 17:41
  • 1
    A major suggestion, don't put HTML in language string if you can help it. Only place I do is my extension description. Other than that, all HTML derives from layouts
    – Lodder
    Commented Jan 11, 2019 at 18:37
  • I see, ok good idea, I'll just create loads of PHPs and each paragraph as a language string. Thanks.
    – Eoin
    Commented Jan 11, 2019 at 19:25

1 Answer 1


This is expected. Language strings must not contain line breaks. Having them would cause invalid INI files. This is not a valid language file:

COM_EXAMPLE_MY_STRING="<h2>This is a heading</h2>
<p>This is some body text</p>"

This is valid:

COM_EXAMPLE_MY_STRING="<h2>This is a heading</h2>\n<p>This is some body text</p>"

Thanks to @lodder for this suggestion

Instead of using HTML in the language string, try creating multiple language strings. Then call each language string independently and use PHP to surround the string with the HTML element you want.

  • Ok fine, I can add \n without getting too upset. How do I stop it showing in the output? In the output I get \\n. Double slash.
    – Eoin
    Commented Jan 11, 2019 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.