Riverbum75
Riverbum75

Reputation: 51

The correct syntax for entering a line break in a JavaScript string?

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.';

Upvotes: 0

Views: 255

Answers (4)

Ozan Deniz
Ozan Deniz

Reputation: 1087

You can use <br> tag for line break

Upvotes: 0

hobbs
hobbs

Reputation: 240010

\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>.

Upvotes: 2

Mathew Thompson
Mathew Thompson

Reputation: 56429

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

Upvotes: 1

Guard
Guard

Reputation: 6955

You wish this break appear in HTML page?

<br> 

then

Upvotes: 1

Related Questions