Home » HTML

HTML Paragraph

HTML paragraph: In this tutorial, we are going to learn about the HTML paragraph tag, how to create a paragraph in HTML, how to format a paragraph in HTML?
Submitted by Jhanvi Tripathi, on July 22, 2019

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.

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.

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

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

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.

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

Some attributes of <p> tag

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.

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.