<div> and <p> elements seem to do the same thing, what are the differences between the two?


#1

Question

I notice I can use either div or p elements in the workspace and the paragraphs seems to display exactly the same. Since it doesn’t seem to matter much one way or another, which element should I use here and why?

Answer

This is a great discovery as it illustrates that div and p elements have something in common: they are both block level elements. As such, the browser renders these elements in the same way. It is up to the developer to pick the tag which best describes the content it will contain. When we are dealing with paragraphs, the semantically correct tag to pick would be the p tag.

As you press on with your learning, keep on experimenting in the workspace!


FAQ: Learn HTML Elements – Intro to HTML – Review
#2

i thought that p element be the bet to implement on a webpage as compared to div element.


#3

I am contain p elements in div & feel good


#4

The elements are ‘semantic’ that means they describe the content between the open and close tags. The p element is paragraph level content, usually text. The div describes a section of a portion of the page or content. Divs usually contain different kinds of content that is all related to a single thing, like an image and an article about it. There is also an ‘article’ tag and a few others that help browsers and, most importantly, search engines find specific content on your web pages.