- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to add a paragraph in HTML?
To define a paragraph in HTML, we use <p> tag. A block of text is representing a paragraph and it always starts on a new line. Before and after a paragraph the browser automatically adds white spaces.
To represent a paragraph in HTML, following syntax is used −
<p>This is a Paragraph</p>
Paragraph consists of open and closing <p> tags.
Following example to add a paragraph in HTML −
<!DOCTYPE html> <html> <body> <h1>How to represent paragraph tag</h1> <p>This is a first paragraph.</p> <p>This is a second paragraph.</p> <p>This is a third paragraph.</p> </body> </html>
Displaying the paragraph on screen
It is not sure that how HTML will display the paragraph on screen, based on screen sizes and resized windows different results will appear.
We cannot change the display of text by adding extra spaces in HTML code. The browser automatically removes any extra spaces and lines whenever a page is displayed.
Consider below example, to see how the <p> tag displays the different arrangement of text on screen −
<!DOCTYPE html> <html> <body> <h2>Different variations on Displaying Paragraph</h2> <p>The statement that i had written contains a lot of lines, but the browser ignores it. </p> <p>The text that i had written contains a lot of spaces but the browser ignores it. </p> <p>The number of lines in a statement depends on the size of window. If i resize that window, the number of lines automatically changes and fit into the screen. </p> </body> </html>
Suppose, if we want to separate the multiple paragraph with a horizontal line in HTML, we use <hr> tag, it is used to separate the content in HTML page with horizontal rule. Following is the example uses the <hr> tag in paragraph.
CSS Settings to <p> tag
Now let us see how to apply the styling to paragraph in HTML by using CSS.
Following example adds add a paragraph in HTML and styles it using the CSS properties –
Kickstart Your Career
Get certified by completing the courseGet Started