A Block of text written in the same context is generally called a paragraph.
In HTML, the element <p> defines a paragraph.
The content of an HTML paragraph is contained between the starting and closing <p> tags.
An HTML document can have multiple paragraphs.
The web browser always displays the content of a paragraph from a new line.
It automatically adds some spacing around the content.
A block of content defined with <p> element can not have a consistent look on the web screen. Its display is adjusted automatically with screen size, i.e. whether the screen size is small or big. Resizing the browser window may also change the view of the paragraph.
When the page is displayed on the screen, the browser automatically removes extra spaces and new lines from the contents of paragraphs.
See the example below.
This is a first pararagraph.</p>
A new line starts from here.
This line has too many spaces.
See how it is displayed on
the screen.
Now, we know HTML removes extra spaces from the paragraph. So what if we need to add an extra space in any line of a paragraph?
For this, we can use an HTML entity named Non-breaking Space (
).If we want to add a line break in a paragraph, we can use <br> element.
The content after the <br> tag starts from a new line.
In the previous chapter: HTML elements, we studied that <br> is an empty element. It means it has no end tag.
In some cases, we don't want to remove extra spaces and new lines from the blocks of text. We want to display them on screen as they are written in an HTML document. In such cases, we use HTML's <pre> element.
The <pre> element defines a preformatted text.
The text between <pre> and </pre> tags is displayed without modification with a fixed-width font.
<pre>Some text to demonstrate pre tag in HTML. See the example to understand it.</pre>
To indent the first line of an HTML paragraph, use the <p> element.
attribute on starting tag ofThe CSS <p> tag to define text indentation.
property is specified as a value in the attribute ofThe <hr> element defines a thematic break in an HTML document.
It is used to insert a horizontal rule.
In a paragraph horizontal rule can be applied to divide a section of text as follows.
The <hr> is an empty element and hence it does not have an end tag.
Tags | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
<p> | Yes | Yes | Yes | Yes | Yes |
<hr> | Yes | Yes | Yes | Yes | Yes |
<br> | Yes | Yes | Yes | Yes | Yes |
<pre> | Yes | Yes | Yes | Yes | Yes |
1. HTML Tutorial |
2. Introduction to HTML |
3. Basic HTML Page |
4. HTML Editors |
5. Web Browser |
6. HTML History |
7. Basic HTML Tags |
8. HTML Elements |
9. HTML Attributes |
10. HTML Headings |
11. HTML Paragraphs |
12. HTML Text Formatting |
13. HTML Styles |
14. HTML Comment |
15. HTML Quotation |
16. HTML Colors |
17. HTML RGB Colors |
18. HTML HEX Colors |
19. HTML HSL Color |
20. HTML CSS |
21. HTML Links |
22. HTML Link Colors |
23. Link within Page |
24. HTML Images |
25. HTML Background Image |
26. HTML Image Map |
27. HTML Picture Element |
28. HTML Favicon |
29. HTML Table |
30. HTML Table Border |
31. HTML Table Size |