The P (Paragraph) element is used to add text paragraphs to an HTML document. Like the H1 element used previously, it is a container element with a start and end tag, and it is a block element that displays white space above and below the element. All text not tagged by other elements should be tagged as paragraph text, using the P element—there should be no untagged text in an HTML document. Add an introductory paragraph to your page (see Figure 2.3).
<body> <h1>Miranda's World</h1> <p>Welcome to my world! My name is Miranda Jones. I'm a sophomore at Excelsior College, majoring in urban horticulture. When not studying, my favorite activity is inline skating, which is great exercise, but also a lot of fun. Continue reading to find out more about my interests, activities, family, friends, hobbies, causes, or anything else I see fit to include. While this page is fairly simple to start out, I hope to expand it later to be much more comprehensive.</p> </body>
Note |
The P element's end tag is officially optional, but the HTML 4.01 specification discourages leaving off the end tag in this instance. Leaving it off can cause problems in some circumstances or when using styles. In this book, all P elements are presented with end tags. |
Tip |
As you create the HTML examples, don't simply rely upon the screenshots to show what your page should look like. Use the figures as prompts to save your HTML in your text editor (File, Save), switch over to your browser, and refresh the display of your page to preview your work. For a shortcut for hopping between your text editor and your browser, use Ctrl+Tab in Windows or Command+Tab on the Macintosh to cycle through open applications. |
It is common to include an introductory paragraph in Web pages. Apart from being a natural way to organize a Web page and introduce its contents, it is also important to understand that search engines and Web directories place special weight upon a page's title, level-one heading, and initial paragraph text when indexing and listing a page. Miranda Jones' introductory paragraph, for instance, contains a couple keyword phrases ("urban horticulture" and "inline skating") that might be used by surfers when searching for a page like hers.