Welcome to the html tutorial and here we will discuss P tag. Here p tag means the paragraph tag or element, it is used to define a block of text as a paragraph.
P tag – definition
“ It is used to create a paragraph in web document.”
P tag – syntax
The paragraph element will start with <p> and ends with </p> tag.
For example:
Let’s write a same content in p tag with two different ways, first p tag has paragraph with weird look and the second p tag has non organized paragraph. Now let’s see what p tag will give in result, when we will run this code.
<html> <head> </head> <body> <p> hi, learning p tag at sharplesson is very easy and user friendly, you can imagine how interactive it is. Let’s make sure we will let others learn with fun. </p> <p> hi, learning p tag at sharplesson is very easy and user friendly, you can imagine how interactive it is. Let’s make sure we will let others learn with fun. </p> </body> </html>
The result will be:
hi, learning p tag at sharplesson is very easy and user friendly, you can imagine how interactive it is. Let’s make sure we will let others learn with fun. hi, learning p tag at sharplesson is very easy and user friendly, you can imagine how interactive it is. Let’s make sure we will let others learn with fun.
You can clearly figure out that the browser has shown output in an organized paragraph.
Note: Browser will remove the extra space or extra line, when content will display.
P tag – Attributes
Now we will see the attributes used by p tag, and it is useful to get proper knowledge before implementation.
- Id – It will specify a unique id for an element.
- Class – A class can be used to apply styles to the paragraph.
- Lang – It is used to define the language used in a paragraph or a web page.
- Style – It is used to specify a style for a particular element.
Note: the align attribute for the paragraph tag has been deprecated and if you want to use align then CSS will help you with that.
Conclusion
Now we have covered p tag, which you can use to arrange your paragraphs. Never forget to close the p tag, you will get the result, even without a closing p tag, but the best practice is to follow the rule and it says “ p tag have opening and closing tag “.