HTML Paragraphs
The HTML p
tag defines a paragraph.
A paragraph always starts on a new line and ends with a new line, and is usually a block of text.
Paragraph element is used to publish the text or content on the web pages.
Note: Browsers will automatically create some margin (white space) above and below the content of a paragraph.
Example
I am a paragraph.
This is another paragraph.
Output
I am a paragraph.
HTML Display
It's impossible to predict how contents (text or images) are displayed in HTML.
Large or small screens and resized windows will create different displays for the same HTML code.
You cannot change the display by adding extra white spaces or extra blank lines between the text in your HTML code.
Any unnecessary white spaces and blank lines between text are automatically removed by the browser by default.
Example
This paragraph
contains a lot of white spaces
and blank lines
but the browser
ignores it.
Output
HTML Horizontal Rules
The hr
tag (horizontal rule) defines a thematic break between paragraph-level elements in an HTML document and is most often displayed as a horizontal line.
The hr
element is used to separate content (or define a change in topic or a change of scene in a story) in an HTML page.
Example
This is heading 1
This is some text.
This is heading 2
This is some other text.
Output
This is heading 1
This is some text.
This is heading 2
This is some other text.
The hr
tag is an empty tag, which means that it has no end tag /hr
Related Links
HTML Line Breaks
The HTML br
tag is used to insert a line break.
Use br
if you want to add a new blank line without starting a new paragraph element.
There are many situations where you can use br
tag. For example, you might want a
series of fixed short lines such as writing a postal address, writing a poem, and so on.
Example
This is
a paragraph
with line breaks.
The
tag is an empty tag, which means that it has no end tag.
Output
This is
a paragraph
with line breaks.
tag is an empty tag, which means that it has no end tag.
The HTML <pre> Element
The HTML pre
tag defines preformatted text.
The pre
tag can be used to display space, tabs, indentation, line breaks, and other elements exactly as they wrote in the HTML file.
It's especially useful when presenting text that requires a lot of white space and line breaks, such as a poem or computer programming code.
Example
My Bonnie lies over the ocean.
My Bonnie lies over the sea.
My Bonnie lies over the ocean.
Oh, bring back my Bonnie to me.
Output
My Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh, bring back my Bonnie to me.
Related Links