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

maxp picture maxp · Aug 11, 2009 · Viewed 22.9k times · Source

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

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

Answer

Christian Hayter picture Christian Hayter · Aug 11, 2009

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 its own, those tags are meant to contain content. They appear to work as paragraph breaks only because when the browser sees them, it "helpfully" closes the current block tag before opening the empty one.