Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Why use the <div> instead of <ul>?
In this video, Guil uses the <div> element to show how bubbling works. He says for performance reasons it is good to select an element close to the actual target. He uses the <div>, but there is an <ul> element one level closer to the <li>s.
What are some reasons to prefer using the <div> instead of the <ul>?
Yu-Che HungCourses Plus Student 10,607 Points
I think that's because he already set a class for the <div> "listDiv" so that he doesn't have to re-do the process again( select the target, addEventListener...etc.)
"div" elements are usually used for styling purposes in the closer future with help of CSS. Several parts of a document can be wrapped inside a div for example and then give it a certain class; for example "container" and then apply certain styles to that div's class, as I said this is just the best practice it seems and this helps to organize your code in a more cleaner and meaningful way in both your HTML and CSS files. Hope it helps, and if I'm wrong I'd be glad to know :) as I'm also currently learning
Will have a good question, does anyone have a good answer? Thank you