An ad-free and cookie-free website.
<p> tag is so easy to learn
because it has no attributes unique to it alone. Of course global
attributes apply, as they do with all elements.
Another simplification is that in HTML5, paragraph styling is set
with Cascading Style Sheets (CSS) instead of inside each
<p> tag sits inside the
<body> element, which means it
is in the visible part of the document.
Its purpose is to create a block of text that shares the same styling
<p> elements on the
As a block-level element, the paragraph element takes up the whole space of its parent element after starting on a new line. This behavior is unlike inline-element that start anywhere in a line.
<p> element holds
other inline elements and are as much about setting the structure, or
the "flow" of a document, as they are about displaying text.
<p> tag in HTML5 it is
advised to use a closing
Because many HTML authors often forget the closing
</p> tag, most browsers will
render the document properly without it.
However, since it is easier to close this tag instead of learn the
rules where it need not be closed, it is better to close it. Many
document validators, like the
W3C Markup Validation Service (opens in a new browser)
are more strict than browsers and will warn you to close this
The text visible on the web page sits between the open and close tags.
<p> element includes no
unique arguments other than global arguments.
Horizontal whitespace is limited to one character in most
browsers, so use the
if you wish to preserve whitespace. Vertical whitespace is trimmed.
HTML code input as above will output the paragraphs shown below.
Carriage returns, extra spaces and text that wraps across several lines will be trimmed within a paragraph element.
This paragraph demonstrates how spacing between two paragraphs can look, depending on CSS settings. Notice extra space between each paragraph?
As for coding style, multi-line paragraphs are often coded with opening and closing tags on different lines like this.
On single lines this format is okay.
As with all tags, Global Attributes can always be set.
<p> element doesn't
have any of its own attributes. That said, the
id global attribute often is used to
identify an element by name.
Each user-agent (browser) has its own stylesheet per se. This dictates
how that browser styles each element by default. The Chrome browser
<p> element using the
The following HTML code will create a paragraph block with the style
attributes specified in a CSS document. Here we also assign the global
id attribute and call it "opening".
Type or copy the lines above into a text file with the .html extension and open it in a browser to see the result.
id attribute can be used to create
a hyperlink to that section using an
<a> tag. See
a tag to learn
about how to anchor a hyperlink.
<p> tag sits within the body
of the HTML document.
See what else you can learn for free at our YouTube Channel. For reminders follow @factorpad on Twitter or join our no-spam email list.
<meta>tag, click Back.
<title>, click Next.
A newly-updated free resource. Connect and refer a friend today.