To write a paragraph in HTML, use the <p> element. Place the paragraph text between an opening <p> tag and a closing </p> tag.
The basic syntax is:
<p>This is a paragraph in HTML.</p>
The <p> element is the standard HTML element for representing a paragraph of text. Browsers automatically display paragraph content as a separate block of text, and default browser styles usually add some space before or after the paragraph.
Basic HTML Paragraph Example
A simple HTML document can contain one or more paragraphs like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Paragraph Example</title>
</head>
<body>
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>
</body>
</html>
Each <p> element represents a separate paragraph. You should not use a single <p> element for multiple unrelated paragraphs. Create a new <p> element whenever a new paragraph begins.
HTML Paragraph Syntax
An HTML paragraph consists of an opening tag, text content, and a closing tag:
<p>Paragraph content goes here.</p>
In this example, <p> tells the browser that the content is a paragraph, while </p> marks the end of that paragraph.
HTML elements generally use this opening-and-closing structure. The closing tag is important because it clearly defines where the paragraph ends.
How to Write Multiple Paragraphs
You can add multiple paragraphs by using multiple <p> elements:
<p>HTML is used to structure content on a web page.</p>
<p>CSS is used to control the presentation and appearance of that content.</p>
<p>JavaScript can add behavior and interactivity to the page.</p>
The browser treats each paragraph as a separate block. This makes the document easier to read and gives the HTML a clear semantic structure.
How to Add a Line Break Inside a Paragraph
Use the <br> element when you need a line break within the same paragraph.
<p>
First line of the paragraph.<br>
Second line of the paragraph.
</p>
The <br> element moves the following content to a new line without creating a new paragraph.
However, <br> should not normally be used to create spacing between separate paragraphs. For separate ideas or sections of text, use multiple <p> elements instead.
For example:
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>
is better than using repeated <br> elements to create paragraph spacing.
How to Format Text Inside a Paragraph
You can use other HTML elements inside a paragraph to give specific text meaning or formatting.
For example:
<p>This is <strong>important text</strong> inside a paragraph.</p>
You can also use <em> for emphasized text:
<p>This sentence contains <em>emphasized text</em>.</p>
Links can also be placed inside paragraphs:
<p>Visit <a href="https://example.com">our website</a> for more information.</p>
Inline elements such as <strong>, <em>, and <a> can be used inside a <p> element because they do not create a separate block by themselves.
How to Change Paragraph Styling with CSS
HTML defines the paragraph’s structure, while CSS controls its visual appearance.
For example:
<p class="intro">This is a styled paragraph.</p>
You can style it with CSS:
.intro {
font-size: 18px;
line-height: 1.6;
margin-bottom: 20px;
}
You can use CSS to control properties such as font size, text color, line height, text alignment, width, margins, and other visual characteristics.
For example, to center paragraph text:
p {
text-align: center;
}
To change the paragraph font size:
p {
font-size: 16px;
}
It is generally better to use CSS for presentation rather than adding unnecessary HTML elements simply to control spacing or appearance.
Should You Use <div> Instead of <p>?
A <div> and a <p> are not interchangeable.
Use <p> when the content is a paragraph of text:
<p>This is a paragraph.</p>
Use <div> as a generic container when you need to group content without the specific semantic meaning of a paragraph:
<div>
<h2>About Us</h2>
<p>This is information about our company.</p>
</div>
Using the correct element gives your HTML a clearer structure and makes the document more meaningful.
Can You Put a Paragraph Inside Another Paragraph?
No. A <p> element should not contain another <p> element.
Incorrect:
<p>
This is a paragraph.
<p>This is another paragraph.</p>
</p>
Instead, use separate paragraph elements:
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>
Each paragraph should be an independent <p> element.
Can a Paragraph Contain Headings?
A heading such as <h1>, <h2>, or <h3> should not be placed inside a <p> element.
Incorrect:
<p>
<h2>Heading</h2>
Paragraph text.
</p>
Use separate elements:
<h2>Heading</h2>
<p>Paragraph text.</p>
This creates a proper document structure where headings identify sections and paragraphs contain the corresponding text.
HTML Paragraphs and Whitespace
HTML does not preserve normal spaces and line breaks in source code in the same way that plain text does. For example:
<p>This is
a paragraph.</p>
will normally be displayed as one paragraph rather than exactly preserving the line break in the HTML source.
If you need a visible line break, use <br>:
<p>This is the first line.<br>This is the second line.</p>
For normal paragraph separation, use separate <p> elements.
Best Practice for HTML Paragraphs
The correct approach is simple: use one <p> element for each paragraph.
For example:
<p>HTML provides the structure for web page content.</p>
<p>CSS controls how that content looks and is presented.</p>
<p>JavaScript adds interactive behavior to web pages.</p>
Use <br> only when a deliberate line break is required within the same paragraph. Use CSS for visual styling and spacing instead of adding unnecessary HTML tags.
Conclusion
To write a paragraph in HTML, use the <p> element and place the text between <p> and </p>:
<p>This is a paragraph.</p>
For multiple paragraphs, use a separate <p> element for each one. Use <br> for a line break within a paragraph, and use CSS when you need to control the paragraph’s appearance, spacing, alignment, or typography. This is the standard and semantically correct way to structure paragraph content in HTML.
Why Not Read This?
How To Convert Ipynb To Html
How To Link An Email In Html
How To Open A Link In A New Tab Html
How To Upload Html File To WordPress
How To Add Schema Markup To Html
How To Call A Function In Javascript From Html
How To Center An Iframe In Html
How To Change Plain Text Email To Html
How To Make Text Wrap Around An Image In Html
Are Html And Css Programming Languages
