Paragraph
Paragraph
HTML paragraphs are used to write text content in a structured and readable way on a webpage. They help divide content into clear sections for better understanding.
Paragraphs are created using the <p> tag.
Each paragraph starts on a new line automatically and is treated as a block-level element, meaning it creates space above and below the text.
They are important for organizing content and improving the clarity and presentation of text on a webpage.
Syntax
<p>This is a paragraph.</p>
Β
Β
Example
<p>This is first paragraph.</p>
<p>This is second paragraph.</p>
<p>This is third paragraph.</p>
Horizontal Rules
The <hr> tag is used to create a thematic break or separation between different sections of content on a webpage. It is usually displayed as a horizontal line.
It helps to show a change of topic or division of content, making the webpage easier to read and understand.
The <hr> element is an empty (self-closing) tag, so it does not need a closing tag.
Β
Example
<!DOCTYPE html>
<html>
<body>
<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>
</body>
</html>
Line Breaks
The <br> element is used to create a line break in an HTML page. It moves the text to a new line without starting a new paragraph.
It is useful when you want to break lines but keep the content in the same paragraph.
Example
<!DOCTYPE html>
<html>
<body>
<p>This is<br>a paragraph<br>with line breaks.</p>
</body>
</html>
Β
pre Element
The pre element is used to display preformatted text in HTML. It shows the text exactly as written in the code, including spaces, line breaks, and formatting.
Example
<!DOCTYPE html>
<html>
<body>
<p>The pre tag preserves both spaces and line breaks:</p>
<pre>
Β Β 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.
</pre>
</body>
</html>
Β