2. Adding Images to Web Pages
Images can be embedded in a webpage via CSS, offering advantages such as responsive design adjustments. CSS can change an image's display properties based on the screen size, ensuring optimal layout across devices.
3. Image File Types
Each image file type has its unique characteristics. Understanding these can help you choose the most suitable format for your website's needs.
- .jpg: Small file sizes ideal for photographs. May lose quality when scaled up.
- .png: Supports transparency and maintains color depth but has larger file sizes.
- .gif: Best for animations but supports limited colors. Often used for small images.
- .svg: Excellent for scalable graphics like logos. Retains quality at any size.
- .webp: Superior compression techniques with smaller file sizes compared to JPG and PNG.
- .pdf: Typically not used for images but useful for documents.
- .tiff: High-quality but impractical for the web due to large file sizes.
4. Steps for Implementing an Image
- Determine the maximum display dimensions of the image.
- Use an image editor to create a canvas at the desired size.
- Insert the image onto the canvas and adjust its size.
- Save the image in the appropriate format.
- Include the image using the
<img>
tag or CSS. - For responsive design, use CSS to control max-width and height.
5. Steps for Getting an Image Ready for Web Use
- Edit the image to the largest needed size, considering device types.
- Save the image in a format that balances quality and load time.
- Use tools to optimize the image size without sacrificing quality.
- Test the image's load time on different devices.
Example Image Embedding:
<img src="images/_skier-700x380.jpg" style="max-width:100%; height:auto;" alt="Photograph of skier on snowy slopes" />