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

HTML

Need help regarding div tag

My question is what exactly is the difference in using img tag within div tag and ouside the div tag as I have noticed while making "Smells like Bakin" project we used <img src...> within div tag at one place and outside div tag at other places. How does this effect the layout?

Thanks in advance

1 Answer

Kevin Korte
Kevin Korte
28,148 Points

It really just comes down to nesting things. Divs do not carry any sort of layout or style inherently. It just kind of says, this is a "block" or "division" of my website. It gives you a hook to style something, or a way to layout multiple elements by putting them all inside of a div.

But divs do not effect layout until you apply styling or positions to them.

Thanks Kevin for your help. That means using img tag within div tag and outside it won't make any difference if we don't wanna change the style of the image?