
- HTML - Home
- HTML - Roadmap
- HTML - Introduction
- HTML - History & Evolution
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <p> Tag
The HTML <p> tag is used to create paragraphs. The <p> tag generates a blank line before and after the paragraph element. The <p> element element is a block-level element, which means it will automatically close if another block-level element is parsed before the closing </p> tag.
Technically, closing the <p> tag is optional, but its good practice to include the closing tag to ensure your document validates. The <p> tag supports both global attributes and event attributes.
Syntax
Following is the syntax of <p> tag −
<p>content</p>
Attributes
The HTML <p> tag supports both Global and Event attributes.
Example: Defining a Paragraph Element
In the following example, we create an HTML document that demonstrates the workings of the <p> tag. Running the code will display the paragraph text on the web-page.
<!DOCTYPE html> <html> <body> <p> Geckos are a group of usually small, usually nocturnal lizards. They are found on every continent except Antarctica. </p> <p> Some species live in houses where they hunt insects attracted by artificial light. </p> </body> </html>
Example: Adding Styles to Paragraph Element
Considering the following example, where we add CSS properties to style the paragraph text. Running the code will display the text with the applied color in the output window.
<!DOCTYPE html> <html> <head> <style> p { color: red; Border: 1px solid red; } </style> </head> <body> <p> Geckos are a group of usually small, usually nocturnal lizards. They are found on every continent except Antarctica. </p> <p> Some species live in houses where they hunt insects attracted by artificial light. </p> </body> </html>
Example: Adding Background Color
Consider the following scenario, where we apply a background color to the paragraph text. Let's look at another scenario, where we apply the background color to the paragraph text. Running the code will display the text with the background color applied on the webpage.
<!DOCTYPE html> <html> <head> <style> p { color: green; Border: 1px solid red; background-color: gray; } </style> </head> <body> <p> Geckos are a group of usually small, usually nocturnal lizards. They are found on every continent except Antarctica. </p> <p> Some species live in houses where they hunt insects attracted by artificial light. </p> </body> </html>
Example: Aligning Paragraph Element
Here, we will use the align attribute to align the paragraph text. Running the code will display the paragraph text aligned in different directions.
<!DOCTYPE html> <html> <body> <p align="center"> Geckos are a group of usually small, usually nocturnal lizards. They are found on every continent except Antarctica. </p> <p align="right"> Some species live in houses where they hunt insects attracted by artificial light. </p> <p align="left"> Some species live in houses where they hunt insects attracted by artificial light. </p> </body> </html>
Example: Default CSS on Paragraph Element
All elements have some build-in styling. In this example, you will see the default CSS of p tag.
<!DOCTYPE html> <html> <head> <style> p { display: block; margin-block-start: 1em; margin-block-end: 1em; margin-inline-start: 0px; margin-inline-end: 0px; } <style> </head> <body> <p> Geckos are a group of usually small, usually nocturnal lizards. They are found on every continent except Antarctica. </p> <p> Some species live in houses where they hunt insects attracted by artificial light. </p> </body> </html>
Supported Browsers
Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
p | Yes | Yes | Yes | Yes | Yes |