-1

I have two images: one for small width and the other for big. I've tried this code but it is not working:

<img src="small.jpg" srcset="big.jpg 401w" alt="xx">
0

1 Answer 1

2

I think this should be a CSS topic and not a php.

You might be missing the rest of the code since all you posted was one line.
You need to to tell the browser when you want the img to change sizes. In the code below it changes at 400px;

<picture>
  <source srcset="small.jpg" media="(max-width: 400px)">
  <source srcset="big.jpg">
  <img src="big.jpg" alt="Flowers" style="width:auto;">
</picture>

source W3c website.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.