Welcome to the Treehouse Community
Looking to learn something new?
Sandro Meschiari18,418 Points
div and section
what is the difference between the section and the div? and when can i use them? can i put a div inside of a section or viceversa? Thank you for your help
There is absolutely no difference between the two, except their name. Other elements like
aside, and probably a couple more that I'm forgetting. Again, these all behave identically to each other and to
div; it's just their names that are different.
The different names make reading and understanding HTML a lot easier, because instead of using
divs everywhere, we can use
nav elements for navigation, or
header elements for headers, or
aside elements for sidebars or something similar.
You might use
section to separate blocks of content from each other. For instance, if I'm working on my blog's homepage, and I want to display my 10 most recent posts there, I might put each post inside its own
section. Inside that, I might use a
div to display my post title.
Hope that helps!
Charlie Jaime17,351 Points
If you like my answer vote me up, or mark me as the best answer. Thank you and great coding!