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

CSS

Faisal Rahimi
Faisal Rahimi
4,019 Points

css/html

can anyone tell me if the folowing code is correct;

(html)

<div id="img1"> <img src="img/babies.jpg" alt="baby photo"> </div>

css

img1{

border: 8px solid #8f583d;

}

on the browser page the above border code covers the image but the right side goes as far as the page width, which i do not want i want the border to rap the image in all sides.

thanks in advance.

Faisal Rahimi
Faisal Rahimi
4,019 Points

on html there is a <div id"img1"> some reason not showing above.

3 Answers

Lucas Santos
Lucas Santos
19,315 Points

Your code is formatted incorrectly but I think I know what it looks like.

You forgot to call your img1 class as a class in your css by forgetting the period before the class name.

If your html is this:

   <div class="img1">
     <img src="img/babies.jpg" alt="baby photo">
   </div>

Then your css should be: (assuming you defined a class)

.img1{
   border: 8px solid #8f583d;
}

Then your css should be: (assuming you defined an ID)

#img1{
   border: 8px solid #8f583d;
}

You call a class in your CSS with a period and you call an id in your CSS with a hashtag.

Faisal Rahimi
Faisal Rahimi
4,019 Points

Hi sorry for the delay. It is an id, sorry my mistake here is the code again; ON HTML---

<div id="img1"> <img src="img/babies.jpg" alt="baby photo"> </div>

ON CSS---

img1{

border: 8px solid #8f583d; }

I have even changed it to class it won't make a difference, the border right side stretches.

Faisal Rahimi
Faisal Rahimi
4,019 Points

for some reason i cannot see the hash-tag before img1.