HTML
html/picture-img
Every picture element ends with an img that has src, alt, width and height; source elements alone render nothing.
poważnastatycznefe-images
Dlaczego
<picture> only chooses a file; the <img> inside it is the element that is displayed, has the accessible name and reserves the space. A picture with sources and no img shows nothing in any browser, and screen readers announce nothing.
Poprawka
Put an <img> last inside the picture with the fallback src, the alt, width and height; <source type="image/avif"> and <source media="…"> before it offer the alternatives.
Przykłady
<!-- bad -->
<picture><source type="image/avif" srcset="hero.avif"></picture>
<!-- good -->
<picture>
<source type="image/avif" srcset="hero.avif">
<img src="hero.jpg" alt="Autumn collection" width="1600" height="900">
</picture>Źródła
Fakty
- Identyfikator
html/picture-img- Waga
- poważna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
htmlangularvuesvelteastrojsx- Uczy jej skill
fe-imagesImages and media delivery- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain html/picture-img