im trying to set image path in picture setsrc but its not set and image is not showing
my code :
<picture>
<source srcset="pngimg.png" media="(max-width: 600px)">
<source srcset="assents\images File\Student hub.jpg" media="(max-width: 1500px)">
<source srcset="assents\images File\Stupid School logo.png">
<img src="img_smallflower.jpg" alt="Flowers">
</picture>
CodePudding user response:
The src
attribute should contain a valid URL. Since space characters are not allowed in URLs, you have to encode them.
You can try
<source srcset="assents\images File\Student hub.jpg" media="(max-width: 1500px)">
<source srcset="assents\images File\Stupid School logo.png">
Or try changing the filename to the one without spaces.
CodePudding user response:
I would not recommend using whitespaces when naming your folders
Whitespace character code is , so you should rename your path to
<source srcset="assents\images File\Stupid&20School logo.png">
However, I would better rename your folders without using whitespace to prevent pain in the future. Valid names could be: images, images-file, imagesFile, images_file, etc.
After renaming files, the source tag would look like:
<source srcset="assents\images\stupid-school-logo.png">