HTML Paragraph

By IncludeHelp Last updated : October 13, 2024

HTML Paragraph

The HTML paragraph is given by the <p> element, that represents a paragraph. A paragraph generally is represented on the webpage as a block of text separated that has first-line indentation and spacing between the lines. In HTML, the paragraph could be a structural group having some relatable content, and the content could be an image or other fields.

A paragraph is a block-level element in HTML. It has a starting as well as an ending tag. The content of the paragraph is present between these two tags.

Example

For example, a simple paragraph in HTML is given as follows:

<p>this is paragraph.</p>

By default, the line break is available with the <p> tag. The text of the paragraph goes within the same line if the break element is not present.

Paragraph without the BREAK element

For example, A paragraph without the BREAK element. It would give output as:

<p>here is a text with no breaking in the line</p>

The output would be as:

here is a text with no breaking in the line

paragraph with the BREAK element

For example A paragraph with a BREAK element. It would give output as:

<p> here is a text <br> with break <br> in the line <br> 
as the BREAK element is present </p>

The output would be as:

here is a text 
with no breaking
in the line
as the BREAK element is present

Paragraph Margins

The paragraph element also has a margin for the text in the paragraph; this margin is present by default. The next line is given as soon as the paragraph ends.

Paragraph Ends could be Ended Automatically

The paragraph ends could be ended automatically as soon as another <p> tag is encountered.

Example:

<p> this is the first paragraph
<p> this is the second paragraph

The output would be as:

this is the first paragraph
this is the second paragraph

Attributes of <p> Tag

1. The align Attribute

This specifies the alignment of the paragraph. The values of the align attribute are LEFT, RIGHT and CENTER. But this attribute has a limitation, that is not supported with the HTML5 version.

2. The style Attribute

The style attribute is used for providing the styling in line with the element. But it also could be given in the style element or by some external CSS file.

Example with attributes

<p style =" display: block;  margin-top: 1em;  margin-bottom: 1em;  margin-left: 0; margin-right: 0;">
    Text here...
</p>

or

<style> p {
    display: block;
    margin-top: 1em;
    margin-bottom: 1em;
    margin-left: 0;
    margin-right: 0;
}
</style>

The <p> tag supports the other global attributes in HTML.

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.