Search code examples
htmlcsssemantic-markup

Use of <p> tag in html


I often come across webpages where, instead of using a separate <div> element to add specific styles, a <p> tag is used.

I would be interested in knowing:

  1. Which is the semantically proper way to add styles - using a <p> tag or a <div> tag?
  2. What are the advantages of using a <p> tag? Does it have anything to do with inheritance?

Solution

  • Which is the semantically proper way to add styles

    There isn't one. Semantics and styles are largely orthogonal considerations. They are related only in so far as most of the time you will want to present semantic information to the reader in a consistent way.

    Write semantic markup, then write CSS that describes how you want it to look.

    What are the advantages of using a <p> tag?

    It defines a paragraph. (A <div> defines a block with no associated semantics).

    Does it have anything to do with inheritance?

    No.