HTML Paragraph

Bookmark
Learn about HTML paragraph tag and difference between Div and P tags.

We should use the <p> paragraph tag element to define text content in a paragraph format in a HTML web page. It should be defined as <p>content</p>. We can safely say that paragraph is the most used HTML tag element in a normal web page. Content enclosed within a HTML paragraph stands out from the content flow as a certain margin space is added before and after the occurrence of the paragraph element by the web browser.

HTML Paragraph Tag Example

Following are two paragraphs with some lorem ipsum test content.

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis tortor massa. Proin nec ultricies mauris. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras pharetra mi risus, vel semper mauris posuere et.</p>

<p>Ut non est sit amet ipsum vestibulum porta. Proin vestibulum lacus rutrum, feugiat leo id, condimentum neque. Praesent vel massa ac diam sollicitudin efficitur sit amet ut nisi. Mauris malesuada luctus diam quis pellentesque. pharetra ornare ligula etm.</p>

Paragraph Example Output:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis tortor massa. Proin nec ultricies mauris. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras pharetra mi risus, vel semper mauris posuere et.

Ut non est sit amet ipsum vestibulum porta. Proin vestibulum lacus rutrum, feugiat leo id, condimentum neque. Praesent vel massa ac diam sollicitudin efficitur sit amet ut nisi. Mauris malesuada luctus diam quis pellentesque. pharetra ornare ligula etm.

HTML Paragraph General Guidelines

  • In a HTML document formation, to define a paragraph we should not add new line by typing "Enter" or new line character. If added, those new lines will be trimmed out by the browser. 
  • Remember to close the paragraph always by adding </p> closing paragraph tag. If the closing tag is not added, some browsers will add them by itself and it may work. But sometimes it can lead to unexpected results. It is a best practice to always close the tag element.

Difference Between <p> and <div>

  • <div> tag is a generic data container.
  • <p> is to be used to define a paragraph content in a document.
  • Do not think about the technical difference, here the semantic difference is the key.
  • Use these tags according to the context of the document flow and the containing element.

Exception Occured:

TypeErrorException
Messageerror_log(app.log): Failed to open stream: Permission denied
File/home/dh_czz6eb/tutorialwalk.com/common/error.php
Line36
Trace#0 (): log_error(2, 'error_log(app.log): Failed to open stream: Permission denied', '/home/dh_czz6eb/tutorialwalk.com/common/error.php', 36)
#1 /home/dh_czz6eb/tutorialwalk.com/common/error.php(36): error_log('09-10-2024 13:11:30 pm (IST),/home/dh_czz6eb/tutorialwalk.com/common/common.php,193,0,ErrorException,Optional parameter $per_page declared before required parameter $href is implicitly treated as a required parameter,/html/html-paragraph.html,#0 /home/dh_czz6eb/tutorialwalk.com/common/error.php(115): log_error(8192, 'Optional parame...', '/home/dh_czz6eb...', 193)
#1 [internal function]: check_for_fatal()
#2 {main}
', 3, 'app.log')
#2 /home/dh_czz6eb/tutorialwalk.com/common/error.php(8): log_exception(ErrorException)
#3 /home/dh_czz6eb/tutorialwalk.com/common/error.php(115): log_error(8192, 'Optional parameter $per_page declared before required parameter $href is implicitly treated as a required parameter', '/home/dh_czz6eb/tutorialwalk.com/common/common.php', 193)
#4 (): check_for_fatal()
REQUEST_URI/html/html-paragraph.html