Table of Contents
What is an HTML Paragraph?
The HTML paragraph tag (<p>) is used to define a paragraph of text. It is the most basic block-level HTML element and is used to contain a single paragraph of text. The paragraph tag automatically adds a line break before and after the text contained within it.
<!DOCTYPE html>
<html>
<body>
<!--visible-start-->
<p>This is a paragraph. This element automatically add spaces on the top and bottom and separates it from other html elements.</p>
<p>This is another paragraph. This element also automatically add spaces on the top and bottom and separates it from other html elements.</p>
<p>This is another tiny paragraph.</p>
<!--visible-end-->
</body>
</html>
HTML Display
Modern web browsers automatically remove extra whitespace when displaying HTML documents. This includes extra spaces, tabs, and line breaks.
<!DOCTYPE html>
<html>
<body>
<!--visible-start-->
<p>This is a paragraph.
it has some extra spaces like
white spaces, line breaks,
and tabs.
But browser will automatically
remove those spaces while
displaying the HTML document.</p>
<!--visible-end-->
</body>
</html>
HTML Horizontal Rules (<hr>)
HTML Horizontal Rules are used to separate content on a webpage. They are created with the <hr>
tag. They can be used to separate sections of a page or to group related elements together.
<!DOCTYPE html>
<html>
<body>
<!--visible-start-->
<h1>This is heading 1</h1>
<p>This is some text.</p>
<hr>
<h2>This is heading 2</h2>
<p>This is some other text.</p>
<hr>
<h2>This is heading 2</h2>
<p>This is some other text.</p>
<!--visible-end-->
</body>
</html>
Note: <hr>
is an empty tag, which means it does not have an ending tag.
HTML Line Breaks
HTML line breaks are used to insert a single line break or a carriage return in an HTML document. It is usually done by adding the <br>
tag within the content that you want to insert a line break.
<!DOCTYPE html>
<html>
<body>
<p>This is<br>a paragraph<br>with line breaks.</p>
</body>
</html>
Note: <br>
tag is an empty tag, which means it does not have an ending tag.
HTML <pre> tag
The HTML <pre> tag is used to display preformatted text. This means that the text is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks. The content of the <pre> tag is displayed in a monospaced font and preserves both spaces and line breaks.
Usually, it is used to show a poem, codes etc.
<!DOCTYPE html>
<html>
<body>
<!--visible-start-->
<pre>
Fade far away, dissolve, and quite forget
What thou among the leaves hast never known,
The weariness, the fever, and the fret
Here, where men sit and hear each other groan
</pre>
<!--visible-end-->
</body>
</html>