Paragraph Tag
intermediatePart of HTML Content & Structure
Theory
The <p> element defines a paragraph — the most common way to structure text content on the web.
How Paragraphs Work
Paragraphs are block-level elements. Each paragraph starts on a new line and browsers automatically add margin space before and after it. This creates visual separation between blocks of text.
Line Wrapping
Text inside a <p> tag automatically wraps to the next line when it reaches the edge of its container. You do not need to manually add line breaks — the browser handles this. Multiple spaces and line breaks within the HTML source are collapsed into a single space.
When to Use Paragraphs
Use <p> for sentences and ideas that form a cohesive thought. Do not use paragraphs just for spacing — that is what CSS margins are for. A common mistake is wrapping every line in its own <p> when a single paragraph with <br> tags would be more appropriate.
Nesting Rules
Paragraphs can contain inline elements like <a>, <strong>, <em>, and <span>. They cannot contain block-level elements like <div>, <h1>, or other <p> tags.
Exercises
Write a Short Biography
Create an HTML page with an h1 heading 'My Biography' and three paragraphs: an introduction, a paragraph about your hobbies, and a paragraph about your goals. Use inline elements in at least one paragraph.
Expected Output:
A page with 'My Biography' as the main heading and three distinct paragraphs, with at least one inline element (strong, em, or a) in a paragraph.