×

HTML Paragraphs

In html, there are some elements which starts with new line and one of them is paragraph. Which is said to be a block of text. In html <p> tag defines a paragraph. In html, browser automatically adds some white space or we can say margin before and after a paragraph, to distinguish it from other things on that web page. Example of how to write a paragraph in html, <p>this is a paragraph</p>.

For example:

<html>
<body>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
</body>
</html>

Output:

HTML Paragraphs

HTML display

One cannot be sure about how the html is going to display the paragraph, because it vary from browser to browser. And on the other hand, other than browser there are many things which can cause trouble displaying paragraph, they are large or small screen sizes, and then we have resized windows, all of them will create different results. While working with html you cannot make changes to the display by giving extra space or extra lines in your html code. Its browsers responsibility to automatically remove all the extra spaces and lines when the page is displayed.

For example:

<html>
<body>
<p>Oxygen is the chemical element with the symbol O and atomic number 8. It is a member of the chalcogen group in the periodic table, a highly reactive nonmetal, and an oxidizing agent that readily forms oxides with most elements as well as with other compounds. After hydrogen and helium, oxygen is the third-most abundant element in the universe by mass. At standard temperature and pressure, two atoms of the element bind to form dioxygen, a colorless and odorless diatomic gas with the formula. Diatomic oxygen gas currently constitutes 20.95% of the Earth's atmosphere</p>
<p>Nitrogen is the lightest member of group 15 of the periodic table, often called the pnictogens. It is a common element in the universe, estimated at about seventh in total abundance in the Milky Way and the Solar System. At standard temperature and pressure, two atoms of the element bind to form dinitrogen, a colourless and odorless diatomic gas with the formula N2. Dinitrogen forms about 78%</p>
<p>The number of lines in the paragraph depends on the size of the browser window. If you resize the browser window, the number of lines in this paragraph will change.</p>
</body>
</html>

Output:

HTML Paragraphs

HTML Horizontal rule

In html, the <hr> tag defines a thematic break in an html page, and it is most often displayed as a horizontal rule. The <hr> tag is used to separate content or we can say it is used to define a change in an html page.

For example:

<html>
<body>
<h1>This is heading 1</h1>
<p>This is some text</p>
<hr>
<h2>This is heading 2</h2>
<p>This is also some text</p>
</body>
</html>

Output:

HTML Paragraphs

Note:

An <hr> tag is empty tag which means it comes without an ending tag or we can say there is no need to put an ending tag after <hr> tag.

HTML line break

We have a <br> tag in html which defines line break. This tag is used to break a line or we can say to start a new line without starting a new paragraph.

For example:

<p>this is<br>a paragraph with line break</p>

<br> tag is also an empty tag which means there is no need to give it ending tags. It comes without ending tags.

For example:

<html>
<body>
<p>This is<br>a paragraph<br>with line breaks.</p>
</body>
</html>

Output:

HTML Paragraphs

The poem problem:

There is a problem with html paragraphs if you want to write a poem, the problem is that our poem will be displayed in a single line.

For example:

<html>
<body>
<p>In html, spaces and new lines are ignored:</p>
<p>
One two buckle my shoe.
Three four shut the door.
Five six pick up sticks.
Seven eight lay them straight.
Nine ten a big fat hen.
</p>
</body>
</html>

Output:

HTML Paragraphs

The output which we are going to get is the same poem but in line not line by line. But we do have a solution to this problem which is html <pre> element.

HTML <pre> element

The html <pre> element is used to define the preformatted text. There are several properties which are predefined in <pre> tags, such as elements are displayed in a fixed width, and they have a courier font usually means it is necessary that they come with courier font, and they preserve both spaces, and line breaks too. You can try it with same example as we have seen in paragraph problem, use <pre> tag instead of <p> tag then see the changes in output.

For example:

<html>
<body>
<p>In html, spaces and new lines are ignored:</p>
<pre>
One two buckle my shoe.
Three four shut the door.
Five six pick up sticks.
Seven eight lay them straight.
Nine ten a big fat hen.
</pre>
</body>
</html>

Output:

HTML Paragraphs

Related Topics

HTML Forms

Forms are required when we want to collect data from the user. Html forms consists of different fields to take user inputs such as: input, text area, checkbox, password, radio...

4 minutes read.

HTML <summary> tag

When we simply want to show the primary heading or topic name of hidden detailed material to users, then we can achieved this by using the summary tag. This makes it...

2 minutes read.

HTML Code Tag

The code tag in HTML is a phrase tag used to insert a piece of computer programming code. In HTML there is a separate tag named as <code> tag. Sometimes,...

3 minutes read.

HTML <select> tag

This tag helps in making the drop-down list on the web page. This is highly used in HTML forms for taking the input from user. You can use the id attribute...

3 minutes read.

HTML Paragraphs

In html, there are some elements which starts with new line and one of them is paragraph. Which is said to be a block of text. In html <p> tag...

4 minutes read.

HTML Elements

An HTML element is nothing but a starting tag and then some content and then the closing tag. So we can say HTML elements is everything from the starting tag...

3 minutes read.

Html &lt;center> Tag

The term HTML refers to Hyper Text Markup Language. The most widely used markup language for making web pages is HTML. A structure of web page is described in HTML....

3 minutes read.

HTML References

BASIC HTML TAGS TAGS DESCRIPTION <!DOCTYPE> Defines Document Type <html> Defines Html document <head> Defines Header of document <title> Defines Title of document <body> Describe all the content of document <h1> to <h6> Defines Html Heading <p> Write Paragraph in this tag <br> Line break <!--...--> Comment in Html FORMATTING TAGS TAGS DESCRIPTION <abbr> Defines...

3 minutes read.

Html Wbr Tag

The Line Break Opportunity element A word break opportunity is a place in text from where the browser breaks a line. This opportunity is represented by the element wbr in the...

2 minutes read.

HTML Layouts

HTML Layouts HTML templates provide a way for well-managed, well-structured responsive web pages to be organized. We could say that the HTML layout specifies how web pages can be set up....

4 minutes read.

HTML <script> Tag

For embedding a client -side script, we use script tag in html tag. This <script> tag can be used for containing scripting statements. It can also point another external script file...

2 minutes read.

HTML Anchor

HTML Anchor The HTML anchor tags define a hyperlink that links to other pages on one page. It can create hyperlinks to any web page and files, locations or any other...

3 minutes read.

HTML Basic Tags

Heading Tags: This tag represents the document header. It is said to be a good practice if every document starts with Heading. Heading tags ranges from H1 to H6 i.e....

3 minutes read.

HTML <svg> tag

SVG is used to determine the vector-based graphics in XML format. What is SVG? We utilize SVG tag to specify visuals for the website. The attribute of SVG in a HTML document...

2 minutes read.

HTML Font Size

The HTML <font> tag uses the size attribute to specify the size of the text. We can set the size attribute’s value from 1 to 7. The default size of...

4 minutes read.

HTML Date

The input element in HTML has several attributes. One of its attributes is the type attribute which creates a calendar in an order that a user can select a date...

5 minutes read.

How to change text color in HTML

Changing the text colour of a web page is essential because it enhances readability. There are several ways to change the colour of the text in HTML, which are as follows: Text...

7 minutes read.

How to add JavaScript to HTML

JavaScript is one of the most important languages today. It is a high-level, interpreted, lightweight programming language that makes web pages more interactive. It is a language of the web....

5 minutes read.

HTML City tag

HTML <City> tag HTML < cite > tag specifies a citation, a reference or title to a creative work, quoted content, books, websites, a research paper, a blog post, a painting,...

3 minutes read.

HTML5 Formatting

HTML Formatting HTML Formatting is a method of text formatting for a better appearance and look. HTML allows us to format text without using the CSS. HTML includes a lot of formatting tags....

6 minutes read.