2021-05-17 15:06:48 +02:00
# No Img Element
2022-06-14 04:17:42 +02:00
> Prevent usage of `<img>` element to prevent layout shift.
2021-05-17 15:06:48 +02:00
### Why This Error Occurred
2022-06-16 04:13:52 +02:00
An `<img>` element was used to display an image. Use either `<picture>` in conjunction with `<img>` element, or use `next/image` that has better performance and automatic Image Optimization over `<img>` .
2021-05-17 15:06:48 +02:00
### Possible Ways to Fix It
Import and use the `<Image />` component:
```jsx
2021-06-16 08:57:45 +02:00
import Image from 'next/image'
2021-05-17 15:06:48 +02:00
function Home() {
return (
< >
< Image
src="https://example.com/test"
alt="Landscape picture"
width={500}
height={500}
/>
< />
)
}
export default Home
```
2022-06-16 04:13:52 +02:00
< br / >
Use `<picture>` in conjunction with `<img>` element:
```jsx
function Home() {
return (
< >
< picture >
< source srcSet = "https://example.com/test" type = "image/webp" / >
< img src = "https://example.com/test" alt = "Landscape picture" / >
< / picture >
< />
)
}
```
2021-05-17 15:06:48 +02:00
### Useful Links
- [Image Component and Image Optimization ](https://nextjs.org/docs/basic-features/image-optimization )