HTML Paragraphs
A paragraph in HTML is defined by the <p>
tag. This tag is used to encapsulate text and group sentences together in a structured way.
When you use the <p>
tag, the browser automatically adds some space before and after the paragraph to separate it from other content on the page, making it easier to read.
Basic Syntax
Here's a simple example of how to use the <p>
tag:
<p>This is a simple paragraph of text in HTML.</p>
In this example, the text 'This is a simple paragraph of text in HTML.' is enclosed within the <p>
and </p>
tags, which tells the browser to treat it as a paragraph.
Adding Multiple Paragraphs
You can add as many paragraphs as you need by using multiple p tags. For example:
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>
<p>This is the third paragraph.</p>
Each paragraph will be displayed on a new line with some space between them.
Paragraph Attributes
The <p>
tag doesn't have a lot of attributes, but there are a few important ones you should know about:
Align: Although deprecated in HTML5, the align attribute was historically used to set the text alignment of a paragraph(e.g., left, right, center, justify).
Example:
<p align="center">This paragraph is centered.</p>