How to Create Paragraphs in HTML5

Paragraphs appear more often than any other text block in web pages. Remember, though, that HTML browsers don’t recognize hard returns that you enter when you create your page inside an editor. You must use a <p> tag to tell the browser to package all text up to the next closing </p> tag as a paragraph.

To create a paragraph, follow these steps:

  1. Add <p> in the body of the document.

  2. Type the content of the paragraph.

  3. Add </p> to close that paragraph.

Here’s what it looks like:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>All About Blocks</title>
  </head>
  <body>
    <p>This is a paragraph. It's a very simple structure that you will use
       time and again in your web pages.</p>
    <p>This is another paragraph. What could be simpler to create?</p>
  </body>
</html>

This HTML page includes two paragraphs, each marked with a separate <p> element. Most web browsers add a line break and a full line of white space after every paragraph on your page, as shown in this figure.

image0.jpg

Sloppy HTML coders don’t use the closing </p> tag when they create paragraphs. Although some browsers permit this dubious practice without yelling, omitting the closing tag isn’t good practice because it

  • Isn’t correct syntax.

  • Causes problems with style sheets.

  • Can cause a page to appear inconsistently from one browser to another.

You can control paragraph formatting (color, style, size, and alignment) with Cascading Style Sheets (CSS).

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.