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!
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
Can't call an image inside a div
I've had this problem in attempts in a row in two different projects.
I am placing an image inside it's own div. When I call the div it has no effect on the image. The only time I can make the image do what I want it to do is when I give the img a class and call that in my css. Here is a quick example:
In this jsbin: http://jsbin.com/ucuwiy/1/edit
My image has a "logoimg" class and is in a div with the class "logo-img". If you look at the css in my jsbin, I am using the class selector .logoimg to center my image. If you edit that class and call it by the div class my image is in by adding a "-" between logo-img, I would think it would still impact the image the same way. Unfortunately whenever I put images inside a div class and give the div class rules to align the image it never impacts the image the way I anticipate it to.
Can you not edit an image position that is inside a div class?
Elliott FrazierCourses Plus Student 9,647 Points
To select a image inside a div you need to first select the class of the div you want selected, like this
.logo-img then add
img to select the
img element inside the
.logo-img div, like this
@Elliot Thanks! I understand now. What is the best practice semantically? Should I make a separate div class for a single image? OR add a class to the image without div tags?