×

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

How to change font in HTML

To give style to the content of your website, you may change the font of the text and make your website look attractive to the user. There are several methods which...

4 minutes read.

HTML <address> Tag

Hyper Text Markup Language, HTML is the best markup language for creating Web pages. HTML consists of a wide variety of elements. In all of these elements, one element is...

4 minutes read.

HTML Lists

HTML List HTML lists are used to specify data sets. All lists can include one or more elements from the list. HTML lists are available in three different types: Ordered List or...

4 minutes read.

HTML Tutorial

Introduction This HTML tutorial helps beginners and professionals to learn HTML easily. HTML is a widely used web technology for website development. It stands for Hyper Text Markup Language. It is mainly used to...

7 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 <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 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 Hide Element

The HTML hide element is used to hide the element. We place the hidden attribute inside those elements which we want to hide. The hidden attribute is a Boolean attribute. The...

3 minutes read.

What does HTML stand for?

HTML stands for Hyper Text Markup Language. We use this markup language to design a web page. Web browsers use this language to showcase text, videos, images, audio and other...

6 minutes read.

HTML Links

It consist of anchor element which is used to create a link between a source anchor and destination anchor. The anchor tag can be embedded between text, image, video or...

2 minutes read.

HTML Font Color

The HTML <font> tag has an attribute called color, which defines the color of the text. We use the color attribute inside the <font> tag to specify the color of...

6 minutes read.

HTML Video

HTML VIDEO: HTML5 has introduced the <video> tag to embed video into the webpage directly without using the plug-ins.   Syntax: <video attributes >     <source src="address" type="video/mp4">     Your browser does not support the video tag.   </video> <video width="320" height="240" controls>     <source src="mountain.mp4" type="video/mp4">     Your browser does not support the video tag.   </video> Output: ← Prev ...

1 minute 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 Button Disabled

The HTML <button> element has many attributes, one of them is the disabled attribute. The button on which you apply the disabled attribute will not work, or we can say...

4 minutes read.

Difference between HTML and DHTML

Introduction to HTML HTML stands for Hypertext Markup Language. It is a standard web language used to create web pages and applications. HTML is used to define the structure and content...

4 minutes read.

HTML Form Input Types

HTML Form Input Types An important element of the HTML form is < input type= "> in HTML. The type attribute of the input element can be of different types, which...

8 minutes read.

HTML Canvas

HTML Canvas: Using JavaScript, the < canvas > tag in HTML is used for drawing graphics on web page. It can be used to draw routes, boxes, text, gradient, and...

3 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 &lt;body> alink Attribute

HTML <body> alink Attribute What is HTML? The HTML or HyperText Markup Language is used to design web pages. The file extension name for HTML file is ".html". It was released in...

2 minutes read.

HTML Unordered List

In HTML, we have <ul> tag which defines the unordered list. And it is also known as bulleted list, because as we know it is not ordered list therefore it...

2 minutes read.