Since "white space" characters are ignored in rendering HTML, the br
element is used for explicit line breaks.
Examples below are from the first part of Paul Revere's Ride
Since "white space" characters are ignored in rendering HTML, the br
element is used for explicit line breaks.
Examples below are from the first part of Paul Revere's Ride
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Using br for line breaks</title> | |
<meta charset="UTF-8"/> | |
</head> | |
<body> | |
<p style="background-color: #ffc">Using br for line breaks:</p> | |
<p>Listen, my children, and you shall hear<br/> | |
Of the midnight ride of Paul Revere,<br/> | |
On the eighteenth of April, in Seventy-Five:<br/> | |
Hardly a man is now alive<br/> | |
Who remembers that famous day and year.</p> | |
<p style="background-color: #ffc">Line breaks and spaces in HTML code don't render...(exception below):</p> | |
<p> | |
Listen, my children, and you shall hear | |
Of the midnight ride of Paul Revere, | |
On the eighteenth of April, in Seventy-Five: | |
Hardly a man is now alive | |
Who remembers that famous day and year. | |
</p> | |
<p style="background-color: #ffc">...except in the "pre" (preformatted) element:</p> | |
<pre> | |
Listen, my children, and you shall hear | |
Of the midnight ride of Paul Revere, | |
On the eighteenth of April, in Seventy-Five: | |
Hardly a man is now alive | |
Who remembers that famous day and year. | |
</pre> | |
<p style="background-color: #ffc">and you can use a non-break space (  or character entities):</p> | |
<p> | |
Listen, my children, and you shall hear<br/> | |
Of the midnight ride of Paul Revere,<br/> | |
On the eighteenth of April, in Seventy-Five:<br/> | |
Hardly a man is now alive<br/> | |
Who remembers that famous day and year. | |
</p> | |
</body> | |
</html> |