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

Max Reinsch
5,740 PointsAspect ratios
I 've been trying to use an image for the background of a page. I want it to fit perfectly but I'm having issues with it. A friend of mine mentioned the aspect-ratio.
Can anybody tell me what an aspect-ratio is and to implement it? In layman's would be tremendously helpful.
Regards, Max.
2 Answers

Wade Christensen
Treehouse TeacherAspect ratio is pretty straightforward once it's broken down. Simply put, aspect ratio is the width of your frame divided by the height of your frame (i.e. the ratio of width to height). Aspect ratio is most commonly expressed as a ratio such as 4:3 or 16:9 (pronounced either "four by three" or "four-three", and "sixteen by nine" or"sixteen-nine"). Again, these ratios are obtained by dividing the width of your frame by the height of your frame. For example, high definition video has a resolution of 1,920 pixels wide by 1,080 pixels tall; dividing 1,920 by 1,080 gives you 1.77777778. Dividing 16 by 9 gives you 1.77777778. 16:9 is just 1.77777778 expressed as a ratio. Most computer monitors today will be somewhere close to an aspect ration of 16:9. If you aren't sure how to get a fraction (ratio) from a decimal it's a little simple math. I can add it to clarify if needed.
The other way you often see aspect ratios expressed is in decimal point form. This is especially true when looking at cinema aspect ratios, which tend to be wider. For example, a common cinema aspect ratio is 2.35:1. Rather than converting everything to a ratio like 16:9, 2.35:1 is saying the aspect ratio is 2.35 times wider than it is tall. This means that a frame that is 20 pixels tall would have to be 47 pixels wide to have an aspect ration of 2.35:1. Multiplying 20 by 2.35 gives you 47.
That's a really long way to say that aspect ratio is width divided by height. The other thing to consider is that in Web design, your aspect ratio is not generally in your control. Someone could access your site with a perfect HD monitor, a phone, a tablet, etc. Every one of those devices has s different aspect ratio. However, if you are working with video or film, aspect ratio becomes very important.
I hope this is explained clearly. If you need more clarification feel free to comment.

Max Reinsch
5,740 PointsThank you very much for the response. I'm off to experiment and I'll let you know how I get on.
Cheers again Wade.

Wade Christensen
Treehouse TeacherNo worries. I come to code as a video professional (among other media things). I'm glad I could help. Let me know how it goes.