freeCodeCamp/curriculum/challenges/english/01-responsive-web-design/responsive-web-design-princ.../use-a-retina-image-for-high...

2.5 KiB

id title challengeType videoUrl forumTopicId
587d78b1367417b2b2512b0a Use a Retina Image for Higher Resolution Displays 0 https://scrimba.com/p/pzrPu4/cVZ4Rfp 301142

Description

With the increase of internet connected devices, their sizes and specifications vary, and the displays they use could be different externally and internally. Pixel density is an aspect that could be different on one device from others and this density is known as Pixel Per Inch(PPI) or Dots Per Inch(DPI). The most famous such display is the one known as a "Retina Display" on the latest Apple MacBook Pro notebooks, and recently iMac computers. Due to the difference in pixel density between a "Retina" and "Non-Retina" displays, some images that have not been made with a High-Resolution Display in mind could look "pixelated" when rendered on a High-Resolution display.

The simplest way to make your images properly appear on High-Resolution Displays, such as the MacBook Pros "retina display" is to define their width and height values as only half of what the original file is. Here is an example of an image that is only using half of the original height and width:

<style>
  img { height: 250px; width: 250px; }
</style>
<img src="coolPic500x500" alt="A most excellent picture">

Instructions

Set the width and height of the img tag to half of their original values. In this case, both the original height and the original width are 200px.

Tests

tests:
  - text: Your <code>img</code> tag should have a <code>width</code> of 100 pixels.
    testString: assert(document.querySelector('img').width === 100);
  - text: Your <code>img</code> tag should have a <code>height</code> of 100 pixels.
    testString: assert(document.querySelector('img').height === 100);

Challenge Seed

<style>

</style>

<img src="https://s3.amazonaws.com/freecodecamp/FCCStickers-CamperBot200x200.jpg" alt="freeCodeCamp sticker that says 'Because CamperBot Cares'">

Solution

<style>
  img { 
    height: 100px; 
    width: 100px; 
  }
</style>

<img src="https://s3.amazonaws.com/freecodecamp/FCCStickers-CamperBot200x200.jpg" alt="freeCodeCamp sticker that says 'Because CamperBot Cares'">