Paragraphs in HTML

HTML paragraphs are a fundamental part of web content, providing structure and readability.Paragraphs in HTML are defined using the <p> tag while each paragraph of text should be enclosed within an opening <p> tag and a closing </p> tag. Each paragraph tag creates a separate block of text, allowing for clear and organized content presentation. In addition, each <p> tag creates a new paragraph and indent to a new line of paragraphs. Here’s example below for Paragraphs in HTML.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Paragraph Example</title>
</head>
<body>
    <p>My first paragraphs.</p>
    <p>My second paragraphs.</p>
</body>
</html>

Paragraph Horizontal line

We can use the <hr> tag create Horizontal line (rules) . The <hr> tag is an empty tag, meaning it doesn’t have a closing tag and is used to create a horizontal line that can act as a divider between sections of content.

Output:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Paragraph Example</title>
</head>
<body>
    <p>My first paragraphs.</p>
    <hr>
    <p>My second paragraphs.</p>
</body>
</html>
Horizontal Line

HTML Line Breaks

Line breaks in HTML are created using the <br> tag. It is the same <hr> tag that this <br> tag is an empty tag, meaning it doesn’t have a closing tag and is used to insert a single line break within text.

The HTML <pre> Element

The HTML <pre> (preformatted text) element is used to display text in a fixed-width font and to preserve both spaces and line breaks. it preserves both spaces and line breaks. It is useful for displaying code blocks or any text where white space and line breaks are significant.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Preformatted Text Example</title>
</head>
<body>
    <p>The following is a preformatted text block:</p>
    
    <pre>
        This my pre tag. I can use it for my own style.
        function hell(){
          echo "Hello world"
        }
    </pre>
   
</body>
</html>

freecode4learn.com

Leave a Reply