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

Mani Saini
Mani Saini
3,101 Points

Image Sizing

The Images used in this project are 1024 * 768 pixels. If i want to use any other pics in my website then how do i change the size of the image? Any Recommended application?

2 Answers

Daisho Komiyama
Daisho Komiyama
15,906 Points

You would want to paste your code next time because it helps us a lot to understand what you want to know.

You can give a class to the img tag then set width: 600px; or any width you want in CSS file.

in html file

<img class="my-pic" src="images/my-pic.jpg">

in css file

.my-pic { width: 600px; }

Mani Saini
Mani Saini
3,101 Points

Hi Daisho, Thanks for explaning. There is nothing that i was trying to do at this stage. I just had this question in my mind so when i do create my own site i can resize images according to the need. Can you explain why we need to use class instead of ID here?

Daisho Komiyama
Daisho Komiyama
15,906 Points

Yes, you can resize images according to the need. You can use an ID instead of a class, but IDs are mostly used in JavaScript to give interactions by convention. I recommend you use classes for styling purposes.