HTML Java

HTML Paragraphs


HTML Paragraphs

  • The <p> tag in HTML defines a paragraph.
  • It has both opening and closing tag.
  • Things within <p> and </p> is treated as a paragraph.
  • Usually browsers read a line as a paragraph even if the closing tag i.e, </p> is not used.

Example

<html>
<body>
   <p>This is paragraph 1.</p>
   <p>This is paragraph 2.</p>
   <p>This is paragraph 3.</p>
</body>
</html>
Try it »

Note: - Browsers automatically add some white space (a margin) before and after a paragraph.



HTML Display

  • You cannot be sure how HTML will be displayed.
  • Large or small screens, and resized windows will create different results.
  • With HTML, you cannot change the output by adding extra spaces or extra lines in your HTML code.

Example

<html>
<body>
  <p>   This paragraph   contains a lot of lines   in the source code,   but the browser   ignores it.   </p> </body>
</html>
Try it »

Note: - The browser removes any extra spaces and extra lines when the page is displayed.



HTML Line Breaks

  • The <br> element defines a line break in HTML.
  • <br> tag is used when there is a need of line break ( a new line) without starting a new paragraph.

Example

<html>
<body>
   <p>This is <br> a paragraph <br> with a line break.</p>
</body>
</html>
Try it »


HTML <pre> Element

  • The HTML <pre> element defines preformatted text..
  • The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks.

Example

<html>
<body>
   <p>The pre tag preserves both spaces and line breaks</p>
   <pre>
   Humpty Dumpty sat on a wall,
   Humpty Dumpty had a great fall.
   All the King’s horses and all the King’s men,
   Couldn’t put Humpty together again.
</body>
</html>
Try it »