When adding images to your website, choosing the right format and optimizing them are key to making your site fast and visually appealing. Here’s a simple guide.
Example:
<img src="https://codersmile.com/images/photo.jpg" alt="A beautiful landscape">
Example:
<img src="https://codersmile.com/images/logo.png" alt="CoderSmile logo">
Example:
<img src="https://codersmile.com/images/animation.gif" alt="Simple animation">
Example:
<img src="https://codersmile.com/images/icon.svg" alt="CoderSmile icon">
Example:
<img src="https://codersmile.com/images/photo.webp" alt="A beautiful landscape">
Optimizing images helps your website load faster and improves user experience. Here are some tips:
Example:
<img src="https://codersmile.com/images/photo.jpg" alt="A beautiful landscape" width="800" height="600">
srcset
and sizes
.Example:
<img src="https://codersmile.com/images/photo.jpg" alt="A beautiful landscape"
srcset="https://codersmile.com/images/photo-small.jpg 500w,
https://codersmile.com/images/photo-medium.jpg 1000w,
https://codersmile.com/images/photo-large.jpg 1500w"
sizes="(max-width: 600px) 500px,
(max-width: 1200px) 1000px,
1500px">
Example:
<img src="https://codersmile.com/images/photo.jpg" alt="A beautiful landscape" loading="lazy">