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

General Discussion

Losing a picture when adding a div

I added a div around a picture and it is removing the picture from my site.

For instance, before I add the div I have: <img src="img/picture-of-me.gif" alt="Picture of Me">

Picture appears on the site!

Then I do the following <div class="grid_3"> <img src="img/picture-of-me.gif" alt="Picture of Me"> </div>

Then the picture is no longer on the site.

Any ideas?

14 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Have you checked what the styles for the class grid_3? Can you post it here?

Thanks for the response!

I suppose that is my confusion. I'm only in the beginner stages of these courses and I am using the grid.css download from one of the beginner courses in css.

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hi Caleb,

It sounds like there's a rule somewhere in your CSS that is hiding the image in grid_3. Like Amit said, have you inspected all CSS properties for grid_3 and any img elements? If you're still having issues, please post your code on http://codepen.io/ and post the link here so we can take a look at it. Thanks!

Thanks again! I hope this helps:

http://codepen.io/CPYLE370/pen/lukme

Caleb, that codepen only shows your HTML; we'd need to see your CSS as well.

Do you have a live link to the website you are working on?

Edit : you also have a few div's with missing closing brackets...

>

I see that, Caroline! Thank you!

Actually, that has corrected all of my issues so far. I'm embarrassed, but this forum has been awesome so far! Thank you so much for all your help!

Haha. Don't be embarrassed. Took me hours the other night just to figure out I was missing a closing div tag. It's good to see we can get the help we need here and can receive the help nicely. Team treehouse for the win!

Thanks, Kris!

OK, so here's where I'm at. Trying to stylize my site and with my css, I'm not getting any of the color added. Any ideas?

http://codepen.io/CPYLE370/pen/LAjdC

Looks like you just need to apply a selector to your styles at the top. If you want the paragraphs to be styled use the p { selector like you did for the a { selector.

Or apply it to your body tag, like so...

body {
  font-family: 'Nunito', sans-serif; color: #FAF3BC; background: #420600 url('img/bg-texture.jpg') repeat;
}

Caroline, that worked! I'm wondering why this worked and not the way I had it? Is there a significant difference I am missing?

you haven't told the CSS what you are applying the styles to ... unless it just got cut-off when you copied+pasted into Codepen? :-/

Caleb, the initial styles in your css weren't attached to any specific element on the page. Caroline's suggestion of adding those to the body tag tells the browser what to attach those styles to...the body of the page.

Thanks guys! This absolutely makes sense.