Scanner class Methods in Java

How to write a program of Paragraphs and Line Break in HTML

Paragraphs



Paragraph is very popular element of language. Paragraph element is used to write content in paragraph format. It gives a paragraph look to the text written between the opening and closing tags of paragraph. we can use simple p tag for paragraph element.

<p>Tag

<ptag is the paragraph tag that is used to create paragraphs in HTML document. <p> tag is a paired tag . It has both opening and closing tags.

Syntax :

<p>Your text here</p>

Let us see a example of paragraph tag:

The HTML:

<html>
<head>
<title>First Paragraph</title>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>
Result:
Writing paragraph in HTML

Note: Browsers automatically add an empty line before and after paragraph.

Single Line Break

Sometime we like to add a empty line before or after text.This empty line can be used before starting document/paragraph or after that, we can also use it in between. This empty line is called as Line Break.
 
For example, I added  a empty line before starting this paragraph.An unpaired tag is used to write line break. This line break is also an element of html.

<br /> Tag

<br /> tag is used to add a line break. It is self closing and unpaired tag.

For example:

The HTML:

<html>
<head>
<title>First Paragraph</title>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<p>This is <br />a line break.</p>
</body>
</html>
Result:
Opening the HTML file in the browser shows that a single line break has been added to the paragraph:

Paragraph and line break example  in html
NoteThe <br /> element is an empty HTML element. It has no end tag.

Comments