HTML Paragraphs(2)
HTML Line Breaks
The HTML <br> element defines a line break.
Use <br> if you want a line break (a new line) without starting a new paragraph:
Example
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph<br>with line breaks.</p>
</body>
</html>
A new webpage open as below:
The <br> tag is an empty tag, which means that it has no end tag.
The Song Problem
This Song will display on a single line:
Example
<!DOCTYPE html>
<html>
<head>
<title> My song lyrics</title>
</head>
<body>
<p>
We're talking away
I don't know what I'm to say
I'll say it anyway
Today is another day to find you
Shyin' away
Oh, I'll be comin' for your love, okay
Take on me
(Take on me)
Take me on
(Take on me)
I'll be gone
In a day or two
So needless to say
I'm odds and ends
But I'll be stumblin' away
Slowly learnin' that life is okay
Say after me
It's no better to be safe than sorry
Take on me
(Take on me)
Take me on
(Take on me)
I'll be gone
In a day or two
All the things that you say, yeah
Is it life or just to play my worries away?
You're all the things I've got to remember
You're shyin' away
I'll be comin' for you anyway
Take on me
(Take on me)
Take me on
(Take on me)
I'll be gone
In a day
(Take on me)
(Take on me)
(Take me on)
(Take on me)
I'll be gone
(Take on me)
In a day
(Take me on)
(Take on me)
(Take on me)
(Take on me)
(Take me on)
(Take on me)
</p>
</body>
</html>
A new webpage open as below:
So, to solve this problem we have a solution.
Solution — The HTML <pre> Element
The HTML <pre> element defines preformatted text.
The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks:
Example
<!DOCTYPE html>
<html>
<head>
<title> My song lyrics</title>
</head>
<body>
<pre>
We're talking away
I don't know what I'm to say
I'll say it anyway
Today is another day to find you
Shyin' away
Oh, I'll be comin' for your love, okay
Take on me
(Take on me)
Take me on
(Take on me)
I'll be gone
In a day or two
So needless to say
I'm odds and ends
But I'll be stumblin' away
Slowly learnin' that life is okay
Say after me
It's no better to be safe than sorry
Take on me
(Take on me)
Take me on
(Take on me)
I'll be gone
In a day or two
All the things that you say, yeah
Is it life or just to play my worries away?
You're all the things I've got to remember
You're shyin' away
I'll be comin' for you anyway
Take on me
(Take on me)
Take me on
(Take on me)
I'll be gone
In a day
(Take on me)
(Take on me)
(Take me on)
(Take on me)
I'll be gone
(Take on me)
In a day
(Take me on)
(Take on me)
(Take on me)
(Take on me)
(Take me on)
(Take on me)
</pre>
</body>
</html>
A new webpage open as below:
No comments:
Post a Comment