Html Paragraph attribute is used to display the paragraph in the browser screen and it was defined with the <p> tag.
- HTML automatically adds an extra blank line before and after the paragraph like a heading.
- Paragraph attribute should be enclose within the body tag.
HTML paragraph tags are used to define the HTML paragraph element. The paragraph element begins with the HTML <p> tag and ends with the HTML </p> tag. The HTML paragraph element should not contain tables and other block elements. A sample is shown below.
This is a sample HTML paragraph element. Any text in a paragraph goes here.
HTML Paragraph Attribute
HTML paragraph element attributes include:
- align – (Depreciated) The align attribute is used to set the alignment of the paragraph with respect to the page size. Values are LEFT, RIGHT, and CENTER. Example: <p align=”center”>
- class – The class attribute is used in conjunction with style sheets to associate an element with a class. The class attribute can set a class for specific element types or it can be independent of element types and work for all elements. The class attribute will provide the settings for specific style formatting. CSS properties are shown at the CSS Properties page.
- ID – The ID attribute is used to apply style settings to specific individual HTML elements.
- style – The style attribute is used to apply style settings for the specific element the style attribute is included with. An example is” <p style=”font: 16pt courier”> – This sets the style or color of the text. This statement starts a paragraph with color, green: <p style=”color: green”>. The STYLE attribute is common to most HTML elements (See the CSS Properties page).
- title – Used to give specific elements a title which may appear as a tooltip in some browsers when the mouse is held at or near the element.
HTML Paragraph Examples
This is the HTML code for a paragraph demonstrating use of the STYLE attribute.
<p style=”text-align: ‘center’; font: ’16pt’; courier; color: ‘blue'”>
The color of the sky and lake is blue.
This example shows how to indent a paragraph using the style attribute:
<p style=”margin-right: ‘5%’; margin-left: ‘5%'”>
This is an example of margin indentation.
Code for Paragraph in html:
Output for Paragraph in html: