--- url: "https://web.dev/learn/images/responsive-images" titulek: "Responsive images | web.dev" h1: "Responsive images Stay organized with collections Save and categorize content based on your preferences." popis: "A deep dive into responsive images." jazyk: "en" kanonicka: "https://web.dev/learn/images/responsive-images" drobecky: ["web.dev", "Resources", "Images"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 22:27:34" znaku: 3869 slov: 573 kodovani: "iso-8859-2" sha256: "74d75ab0050f16842a6246f4063d0178468222cba1be9f7f1e8ae8809157390e" --- Responsive images Stay organized with collections Save and categorize content based on your preferences. [Responsive image](/learn/design/responsive-images) markup can be divided into two scenarios: situations where the goal is the most efficient possible images, and situations where you need explicit control over what image source the browser selects. You can think of these as *descriptive* and *prescriptive* syntaxes, respectively. In this module you'll learn both approaches. First we'll cover `srcset` and `sizes`, and how to help the browser make the best choice based on what it knows about the user, their device, and their browsing situation. You'll then discover the `` element, which allows for explicit control over source selection based on factors like viewport size and browser support for image formats. Descriptive syntaxes A descriptive syntax provides the browser with information about image sources and how they'll be used, but ultimately leaves the decision-making to the browser. This is by far the more common scenario; for the vast majority of images you won't *want* granular control over browser behavior. Browsers have far more information at their disposal than web developers do, and can make complex decisions based on this information. You can't predict users' browsing contexts accurately—there's too much about their hardware, preferences, and connection speeds that you can't know. At best, you can make educated guesses, but can't know for *certain* how each user experiences the web. The central use case for responsive images is strictly goal-oriented, from a developer's perspective: allow browsers to make the most efficient image requests possible, based on the information the browser has at hand. To enable browsers to make these choices, `srcset` allows you to provide the browser with a list of potential sources for populating a single ``, while `sizes` allows you to provide the browser with information about how that `` will be rendered. You'll learn how to use these in the [next module](/learn/images/descriptive). Prescriptive syntaxes With a prescriptive syntax, you tell the browser what to do—what source to select, based on specific criteria you've defined. While this use case isn't as common as "just load the most efficient asset to render this image," it allows us to provide usage instructions to the browser to account for information it doesn't have prior to the transfer of assets, such as the content of the sources or their formats. While `srcset` and `sizes` provide you with a syntax for passing information along to the user's browser and allowing it to make decisions about image sources, there are times when you'll need explicit control over which source file is presented and when. For example, you might want to display versions of the same image content with different aspect ratios, based on different design treatments across layout breakpoints, or make sure only browsers with support for a specific encoding receive specific sources. In these cases, you want explicit control over which source is shown, and when. These are assurances that `srcset` and `sizes` can't give us, by design. To get that control, we'll need to use the [`` element](/learn/images/prescriptive). [Previous arrow_back Image formats: AVIF](/learn/images/avif) [Next Descriptive syntaxes arrow_forward](/learn/images/descriptive) Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2023-02-01 UTC.