Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can we give a <picture> element link to other page?

Tags:

html

I have this kind of code:

<picture>
    <source srcset="Img/material.jpg" media="(min-width: 401px)">
    <source srcset="Img/materialw400px.jpg" media="(max-width: 400px)">
    <img id="material" srcset="Img/material.jpg" alt="Material">
</picture> 

the question is, can we give that picture a link to other page?

I've already tried using <a> tag before the <picture> tag and inside the tag but none of these is working.

like image 691
DreLouder Reaper Avatar asked Oct 21 '25 16:10

DreLouder Reaper


1 Answers

<a target="_blank" href="http://php.net">
    <picture>
       <source media="(min-width: 401px)" srcset="Img/material.jpg"></source>
       <source media="(max-width: 400px)" srcset="Img/materialw400px.jpg"></source>
       <img alt="Material" srcset="Img/material.jpg" id="material">
    </picture> 
</a>

It works fine.

like image 161
Amit Avatar answered Oct 23 '25 06:10

Amit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!