Paragraphs
In HTML, paragraphs are defined using the <p> tag. Paragraphs help break
your content into readable blocks of text. Each <p> element
creates space before and after the paragraph, making your content more
structured and easier to read.
๐ Syntax:
<p>This is a paragraph of text.</p>
๐ง Key Points:
·
The <p> tag is a block-level element, which means it always
starts on a new line.
·
Browsers automatically add
some spacing (margin) before and after a paragraph.
·
Text within <p>
tags will automatically wrap to the next line when it reaches the end of the
container.
✅ Example:
<!DOCTYPE html><html><head> <title>Paragraph Example</title></head><body> <h1>Welcome to My HTML Page</h1> <p>This is the first paragraph. It introduces you to the content of the page.</p> <p>This is another paragraph. Notice how each paragraph is separated by some space.</p></body></html>
๐งช
Testing with XAMPP/WAMP:
1.
Open your code editor and create a
new file named paragraph-example.html.
2.
Paste the example code above.
3.
Save the file in your XAMPP or
WAMP www
or htdocs
folder.
4.
Open your browser and navigate to:
http://localhost/paragraph-example.html
5.
You will see the heading and two
paragraphs displayed with spacing in between.
๐ก Tips:
·
Don’t use <p>
tags around other block-level elements like <div>, <table>,
or another <p>.
Nesting block elements inside <p> is invalid HTML.
·
For line breaks inside a
paragraph without starting a new paragraph, use the <br> tag.
<p>This is a single paragraph.<br>But this part appears on a new line.</p>