Search code examples
htmllayouttagsmarkup

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?


Solution

  • 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.