Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Size mobile slider images to match the carousel’s actual CSS slot—not a universal pixel rule. Measure the slot at your narrowest supported breakpoint, create a small set of appropriately sized image files, and let srcset and sizes help the browser choose a candidate. If mobile needs a different composition, provide a separate crop. Reserve space with dimensions, prioritize the first visible slide, and avoid downloading every hidden slide up front.

What size should a slider image be on mobile?

There is no one correct mobile slider width. It depends on the width the layout renders and the device pixel ratio (DPR) of the screen. A full-bleed slide may occupy nearly the viewport width; a slide inside a page gutter or card occupies less. Measure the rendered slot in CSS pixels first, then generate image candidates that cover that slot at the densities you want to support.

As a starting point, Google web.dev says three to five image sizes are common, and its responsive-image example uses 320w, 480w, and 800w candidates. Those figures are examples, not a prescription for every carousel. Serving desktop-sized images to mobile can use 2–4x more data than needed, according to Google web.dev’s guidance updated November 29, 2022. The practical fix is not to make every file arbitrarily small: it is to offer candidates appropriate to the component’s actual layout.

Measure the slot before exporting

  1. Open the page at the narrowest supported mobile breakpoint.
  2. Measure the slide’s rendered width in CSS pixels. For a full-bleed slide this may be close to viewport width; for a slide with gutters, subtract the gutters.
  3. Multiply that CSS width by the target DPR to estimate the source width for a sharp image on that display.
  4. Generate a few candidate widths spanning your actual breakpoints and expected display densities. Avoid candidates that are all much larger than the slot or so close together they add complexity without useful choice.

For example, if a slide renders at 360 CSS pixels and you want a source suitable for a 2x screen, a source around 720 pixels wide may be appropriate. That does not mean every visitor should download a 720-pixel file: responsive candidates allow the browser to make a selection based on the slot and device.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How srcset and sizes choose an image

srcset lists alternate image files and their intrinsic widths. The w descriptor tells the browser the width of each file in pixels. The sizes attribute describes the image’s expected rendered slot width at different viewport conditions. The browser combines that information with its display and loading context to select a candidate.

sizes does not resize the image or set the layout width. CSS controls the rendered dimensions; sizes is a hint about those dimensions so the browser can choose efficiently. Keep a src fallback even when using srcset or <picture>.

<img
  src="hero-800.jpg"
  srcset="hero-320.jpg 320w,
          hero-480.jpg 480w,
          hero-800.jpg 800w"
  sizes="(max-width: 480px) 100vw, 800px"
  width="800"
  height="450"
  alt="A hiker looking across a mountain lake">

Here, the browser is told that the image slot is the full viewport width at widths up to 480 pixels, and 800 pixels otherwise. Change those conditions and candidate widths to match your real CSS and image files. If the desktop slot is not 800 pixels, or mobile has horizontal padding, the example’s sizes value will not describe your page accurately.

Make the attributes agree with the CSS

A common responsive-image mistake is writing a plausible sizes expression that does not match the component. If CSS renders the slide at 92vw on mobile because of side gutters, but sizes says 100vw, the browser may choose a larger file than needed. If the declared slot is narrower than the real slot, the browser may select an image that looks soft on a high-density display. Keep the CSS layout rule and sizes expression aligned as the design changes.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should mobile and desktop sliders use different images?

Use the same image candidates when the composition works at both sizes and only the resolution needs to vary. Use a separate mobile crop when the narrow frame needs a meaningfully different composition—for example, when a wide desktop image would make its subject too small or cut off important content on a phone. Do not stretch one source to force it into a different aspect ratio.

For a fixed-height card or hero, choose the crop intentionally. CSS can preserve proportions when the whole image should remain visible, or use a documented crop rule such as object-fit: cover when the frame should be filled. With a cover crop, keep faces, product details, and embedded text inside a safe area likely to remain visible. If a crop changes the message or hides essential subject matter, create an art-directed mobile source instead.

Use picture for art direction

The <picture> element lets you offer a source for a media condition, followed by a fallback <img>. Give the mobile source its own dimensions when its aspect ratio differs, and retain dimensions on the fallback image as well.

<picture>
  <source
    media="(max-width: 600px)"
    srcset="hero-mobile-480.jpg 480w, hero-mobile-720.jpg 720w"
    sizes="100vw"
    width="720"
    height="900">
  <img
    src="hero-desktop-1200.jpg"
    srcset="hero-desktop-800.jpg 800w, hero-desktop-1200.jpg 1200w"
    sizes="(max-width: 900px) 100vw, 1200px"
    width="1200"
    height="600"
    alt="A person testing a camera outdoors">
</picture>

The example’s widths and ratios are illustrative. Export dimensions that match your own crop files, and ensure the media conditions correspond to the breakpoints where your design switches sources.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prevent layout shift when slider images load

Set intrinsic width and height on images so the browser can reserve space before the file arrives. The ratio matters: a 1200-by-600 desktop image reserves a 2:1 frame, while a 720-by-900 mobile crop reserves a 4:5 frame. If the mobile source uses a different ratio, provide its own dimensions on the corresponding <source> and keep the fallback image dimensions accurate too.

For a component whose design requires a fixed frame, CSS aspect-ratio can reserve that frame. A separate crop rule such as object-fit: cover then describes how the image fills it. Do not put a desktop ratio on every source merely because the desktop file was exported first; the wrong reservation can cause a visible shift when a differently proportioned mobile image appears.

How to keep a mobile carousel from slowing the page

The first visible slide is often a strong candidate for the page’s Largest Contentful Paint (LCP) image. Load it eagerly, and use fetchpriority="high" when it is the LCP element. Avoid eagerly downloading every image in the carousel: render only the first few initially and add later slides as the user navigates, or defer those later images. This limits initial image bytes and competition for bandwidth on mobile connections.

<img
  src="slide-one-800.jpg"
  srcset="slide-one-480.jpg 480w, slide-one-800.jpg 800w"
  sizes="100vw"
  width="800"
  height="450"
  fetchpriority="high"
  alt="A close-up of the product in use">

Use high priority selectively for the image that is actually visible and important to the initial render. Applying it to every slide defeats the purpose of prioritization. For off-screen slides, use your carousel’s navigation and rendering behavior to avoid fetching or creating all image elements at once. If images are already present but not initially visible, lazy loading can defer later downloads; check the carousel implementation to ensure it does not make the first visible image wait unnecessarily.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make carousel controls usable on touch screens

Make slider controls at least 44 × 44 CSS pixels, with whitespace around them so they are easier to target. Give each button an accessible name such as “Next slide” or “Previous slide,” and communicate the active slide using more than color alone—for example, a position indicator with a distinct shape or text. If text or controls overlay photography, preserve sufficient contrast against the image.

Also check that controls remain reachable when a mobile crop changes the subject’s position. A visually attractive desktop overlay can cover the focal content or become hard to tap on a small screen. Test the real mobile composition, not just the image asset in isolation.

Generate responsive slider files

For a build pipeline, Google web.dev identifies the Sharp npm package and ImageMagick as popular resizing tools. An image service such as Cloudinary can generate responsive variants and manipulate images on demand. These are implementation options rather than requirements; choose based on where your source images live, whether you want transforms during build or request time, and how much control you need over output files.

Whichever approach you choose, generate width candidates from measured component slots and preserve the intended crop. Name or map files consistently so the HTML references the right width descriptor. A file called hero-800.jpg should actually be about 800 pixels wide if it is declared as 800w; incorrect descriptors can cause the browser to make a poor selection.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the rendered slider, not just its source files

Validate the slider at the smallest viewport you support and at larger breakpoints. Confirm the crop, dimensions, selected source, and loading behavior in the browser. A screenshot is useful for checking whether the mobile composition keeps its subject, text, and controls in the intended places; it does not by itself tell you whether the browser downloaded the smallest suitable candidate or whether later slides were deferred.

For repeatable page captures while checking responsive layouts, ScreenshotNeo is a website screenshot API and MCP server for developers. It can capture pages at different viewports, but image sizing and carousel loading still need to be verified against the page’s actual browser behavior.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

One GET request can return a page screenshot. Use an access key and replace the example URL with the page you want to inspect. See the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

For this kind of visual QA, ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response includes X-Page-Verdict and X-Billed headers. Its MCP server gives AI agents tools including take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Troubleshooting common slider-image problems

The mobile image looks soft

Check the actual rendered slot width, the source file’s pixel width, and the device density you intend to support. Then inspect whether the browser selected the expected candidate. If your sizes value understates the slot, correct it; if the candidate set lacks a sufficiently wide file for the target density, add one. Do not solve softness by making every mobile visitor download the largest desktop asset.

The phone downloads a file that seems too large

Compare the CSS slot with the sizes expression and the actual widths in srcset. Check for inaccurate descriptors or a media condition that reports the wrong slot. A full-width declaration is inappropriate when the image is rendered inside substantial gutters.

The page jumps when the slide appears

Supply accurate intrinsic width and height so the browser can reserve the source’s ratio before loading. If art direction changes the ratio, declare dimensions for the mobile source and fallback separately. For a fixed-frame design, reserve the frame with aspect-ratio and use a deliberate crop rule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The first slide appears late

Make sure the initially visible slide is not being lazy-loaded along with later slides. If it is the LCP image, load it eagerly and consider fetchpriority="high". Also check whether carousel initialization or delayed source insertion is keeping the image from being requested promptly.

Later slides slow the initial page

Do not create or eagerly download the entire hidden carousel by default. Render only the first few images initially and load additional ones as the visitor navigates, or defer later slides. Confirm in the browser that the carousel’s JavaScript and markup actually implement the intended behavior.

The mobile crop cuts off important content

Do not stretch the desktop file to a new ratio. Provide an art-directed mobile crop, move important subjects into a safe area, or change the frame behavior. Review overlaid text and controls against the actual crop at narrow widths.