One of the most basic HTML tags is the paragraph or <p> tag.
It’s almost impossible to talk about HTML without talking about CSS anymore.
Remember that HTML is for structuring your document, not styling your document, so the paragraph tag should only be used when you have legitimate paragraphs in your web page. This means that the sole purpose of the paragraph tag is to indicate to the browser that the text between the <p> and </p> is a complete paragraph. It also indicates that any CSS code for <p> tags should be applied to this text.
With that said, there are a few attributes that can be used with the paragraph tag that might help.
The ‘class’ and ‘id’ attributes will be the most common used now because they help attach CSS styles and Javascript events to specific paragraphs.
<p id="paragraph_1" class="center">This is my paragraph text.</p>
Another popular attribute may be the ‘style’ attribute because it allows us to put CSS inline:
<p style="color: blue; padding: 10px">This is my blue, padded paragraph.</p>
You may see the ‘align’ attribute a lot on the paragraph tag, but this attribute has been deprecated in favor of adding CSS to justify the paragraph text. The values for the ‘align’ attribute were ‘left’, ‘right’, ‘center’ and ‘justify’. You may see those in code, but you should refrain from adding them to new code since browsers in the future may drop them since they are deprecated. That will be a hard habit to break for me.
We used to use the paragraph tag for line spacing, but CSS can now control all your spacing needs.
There are some lesser used attributes for the paragraph tag. For those attributes, I’ll share the paragraph tag page from one of my favorite sites for checking out HTML tags and their attributes.
Paragraph tags make it very easy to tie your text to your stylesheets. You can style the paragraph tags once in your stylesheet and not have to worry about the style in your HTML document.