0

What is the correct syntax to insert a line break in a string? I have tried '\n' but this doesn't work...? This is the string in question:

    function layer0(){
  document.getElementById('layerinfo').innerHTML = 'The Wembury Quest ran during June   2012 and was very popular in the parish. Over 400 quest packs were collected from the village school post office and local shops. The Quest was designed to encourage residents to go out into the parish and explore their local landscape. This layer shows the results from the letterboxes. For the letterboxes twelve locations were chosen, spread around the parish. They were picked to take participants to very different types of landscape and views. Some of them were places which they had visited before, and some were off the beaten track and were new to some Questers. All of the locations were found on public rights of way.';
2
  • 1
    <br/>.............. Commented May 8, 2013 at 21:49
  • I tried that as well...! Commented May 8, 2013 at 21:52

4 Answers 4

2

\n is the correct syntax for inserting a line break in a string. Your problem is that you don't want to insert a line break in a string. You want to insert the text <br> in a string. The correct syntax for inserting the text <br> in a string is <br>.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks... <br/> I tried and it didn't work, but <br> as you suggested did. I presume that you can only use the latter in a JS string then?
@Riverbum75 no, don't presume anything like that.
1

You wish this break appear in HTML page?

<br> 

then

Comments

1

The <br /> tag, as you're using innerHTML

Comments

0

You can use <br> tag for line break

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.