Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use the <p /> tag in markup?

I have always used either a <br /> or a <div/> tag when something more advanced was necessary.

Is use of the <p/> tag still encouraged?

like image 742
maxp Avatar asked Aug 11 '09 15:08

maxp


People also ask

When should I use P tag?

The <p> tag defines a paragraph. Browsers automatically add a single blank line before and after each <p> element. Tip: Use CSS to style paragraphs.

Why do we use P and </ p tags?

It defines a paragraph of text. The end of the paragraph is marked by a closing </p> tag. Technically this is optional, but it's good practice to include the closing tag to ensure your document validates. By default, most browsers place a line break and a blank line between paragraphs.

Should I use SPAN or P?

The p tag denotes a paragraph element. It has margins/padding applied to it. A span is an unstyled inline tag. An important difference is that p is a block element when span is inline, meaning that <p>Hi</p><p>There</p> would appear on different lines when <span>Hi</span><span>There</span> winds up side by side.

Does P need a closing tag?

P-end-tag (</p>) is not needed in HTML [closed]


1 Answers

Modern HTML semantics are:

  • Use <p></p> to contain a paragraph of text in a document.
  • Use <br /> to indicate a line break inside a paragraph (i.e. a new line without the paragraph block margins or padding).
  • Use <div></div> to contain a piece of application UI that happens to have block layout.

Don't use <div /> or <p /> on their own. Those tags are meant to contain content. They appear to work as paragraph breaks only because when the browser sees them, and it "helpfully" closes the current block tag before opening the empty one.

like image 197
Christian Hayter Avatar answered Oct 11 '22 14:10

Christian Hayter