Use CSS Grid for the layout and real <img> elements for the images. For evenly filled tiles, give each image a consistent box and use object-fit: cover; to show every part of each source image, use object-fit: contain and accept possible empty bands. The example below is responsive, reserves space while images load, and includes accessible alternative text.
Build a responsive image grid
This gallery uses CSS Grid’s fluid column tracks, so the number of columns changes as the available width changes. There is no universal column count or breakpoint: choose tile sizing to suit the images and page, then check the result on narrow screens and at increased zoom.
<ul class="gallery">
<li>
<img src="images/coast.jpg" alt="Rocky coastline beside blue water"
width="1200" height="800" loading="lazy">
</li>
<li>
<img src="images/market.jpg" alt="Produce stalls at an outdoor market"
width="1200" height="800" loading="lazy">
</li>
<li>
<img src="images/architecture.jpg" alt="Arched windows on a brick building"
width="1200" height="800" loading="lazy">
</li>
<li>
<img src="images/garden.jpg" alt="Flowers growing along a garden path"
width="1200" height="800" loading="lazy">
</li>
</ul>
* { box-sizing: border-box; }
.gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
gap: 1rem;
list-style: none;
margin: 0;
padding: 0;
}
.gallery li {
aspect-ratio: 3 / 2;
min-width: 0;
overflow: hidden;
}
.gallery img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
The HTML list communicates a collection, while CSS controls its presentation. The minmax() track allows columns to flex; auto-fit fits as many tracks as the available width allows. The nested min() prevents the minimum track width from forcing overflow when the container is narrower than the preferred track size. Change 16rem to tune the preferred minimum tile width, rather than treating it as a required breakpoint.
The tile’s aspect-ratio establishes a consistent shape. The image fills that box without stretching because of object-fit. The specified HTML width and height describe the source image’s intrinsic proportions and help the browser reserve layout space before the file arrives.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Choose between cropping and showing the whole image
The key visual decision is whether consistent tiles or complete image visibility matters more. MDN explains the behavior of images in CSS layouts and object-fit.
| Setting | What it does in a fixed box | Best when |
|---|---|---|
object-fit: cover |
Preserves the image’s proportions while filling the box; some content at the edges may be cropped. | Uniform tile shapes matter more than showing every pixel. |
object-fit: contain |
Preserves the entire image; unfilled space may remain inside the box. | The full image must be visible, such as for diagrams or product details. |
To show complete images instead, replace the last declaration with object-fit: contain. The unused area can be given a background color on the image or its tile. If a fixed, uniform tile is not necessary, remove the tile’s fixed sizing strategy and let image proportions determine their displayed height; that avoids introducing blank bands just to keep every tile the same shape.
With cover, inspect the crop for each image. A centered crop may cut off a face, label, or other important subject. Where the browser should focus a different part of an image, set an image-specific object-position, for example object-position: 70% center. This changes the crop position; it does not restore content outside the box.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Make the grid reflow instead of overflow
A grid with a fixed number of wide columns can exceed a small viewport. The fluid track definition in the example lets the grid create fewer columns as space narrows. Alternatively, use media queries when the design calls for deliberate column counts at chosen widths:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11.gallery {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 1rem;
}
@media (max-width: 48rem) {
.gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 32rem) {
.gallery { grid-template-columns: 1fr; }
}
Those values are examples, not standards. Set breakpoints based on when the actual tiles become too cramped for their contents. W3C WAI describes media queries with Grid as one technique for reflowing columns; it is an informative technique, not a mandated implementation.
Check the gallery at narrow widths and increased zoom. A tile may become too small even when the grid technically fits, and fixed minimum track sizes can still cause horizontal scrolling if they exceed the available space. For image fitting during reflow, WAI also documents using max-width and height as an informative technique.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Use responsive image sources when sizes vary
CSS controls how an image is displayed; responsive image markup can let the browser select a suitable file. If a gallery is shown at different rendered sizes, offering smaller and larger resources can avoid always requesting the same source file. MDN’s responsive images guide explains srcset, sizes, and art direction with <picture>.
<img
src="images/coast-800.jpg"
srcset="images/coast-400.jpg 400w,
images/coast-800.jpg 800w,
images/coast-1200.jpg 1200w"
sizes="(max-width: 32rem) 100vw,
(max-width: 48rem) 50vw,
33vw"
width="1200" height="800"
alt="Rocky coastline beside blue water"
loading="lazy">
The width descriptors in srcset identify the resource widths. The sizes value describes the image’s expected layout width at the listed conditions, helping the browser choose among them. Adjust these conditions to match the actual gallery container and column layout; they are illustrative, not universal. Supply alternatives that suit the displayed slot rather than assuming that one source size fits every device.
Use <picture> with <source> when you need to offer different image formats or art-directed crops under conditions you define, with an <img> fallback. For ordinary resolution selection, srcset and sizes on <img> are often enough. See MDN’s guidance on using images in HTML.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Write useful alternatives and avoid layout shift
For meaningful content images, write concise alt text that conveys the information relevant to the page. Do not repeat a nearby caption word for word if it adds nothing. For a purely decorative image, use the appropriate alternative-text treatment for its context rather than inventing a description. MDN’s <img> reference covers alternative text, dimensions, and loading behavior.
Include width and height attributes based on the source image’s intrinsic dimensions. They give the browser information to reserve the correct proportional space before an image loads. CSS can still scale the image to its tile. If dimensions are absent, the layout may shift as image files arrive.
loading="lazy" is appropriate for images initially outside the visible area, such as lower rows in a long gallery. Avoid applying it indiscriminately to images expected to appear immediately: deferring their requests can postpone their display. Lazy loading changes when a browser requests an image; it does not make the source files smaller.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Troubleshoot common image-grid problems
- Images look stretched: Width and height may both be forced without a fit strategy. Preserve the image’s proportions with
object-fit: coverorcontainin a defined box, or allow its height to follow its natural ratio. - Important parts are cut off: That is expected with
cover. Switch tocontainwhen full visibility is essential, or adjustobject-positionfor the crop that should remain visible. - Tiles have empty bands: That is expected with
containwhen the source and box aspect ratios differ. Usecoveronly if cropping is acceptable, or let image proportions determine tile height. - The page jumps as images load: Add correct
widthandheightattributes, and check that CSS does not contradict the intended proportions. - The grid scrolls horizontally on a phone: Check fixed column counts, minimum track widths, and container padding. Let the tracks reflow or add a narrow-screen rule; verify at narrow widths and increased zoom.
- Images appear soft or download unnecessarily large files: Provide suitable source variants with
srcsetand an accuratesizesdescription. Verify the browser is offered resources appropriate to the rendered slot.
Or skip the browser setup
If you need a screenshot of the finished page rather than a gallery embedded in your site, ScreenshotNeo can return a screenshot or PDF from one GET request. Its clean-shot steps accept cookie and consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client. The service includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000.
Install Python’s requests package, replace the key, and save the returned image bytes. See the ScreenshotNeo API documentation for request options.
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://example.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
Sign up for 1,000 free screenshots a month with no card.
Sources and implementation references
- MDN: Images, media, and form elements — Learn web development
- MDN: Using responsive images in HTML
- MDN: Using images in HTML
- MDN:
<img>: The Image Embed element - W3C WAI: C37, Using CSS max-width and height to fit images
- W3C WAI: C32, Using media queries and grid CSS to reflow columns
Frequently Asked Questions
Should I use a CSS background image for each gallery item?
Use an HTML <img> when the image conveys page content so it can have alternative text and responsive image attributes. A CSS background is more appropriate for decoration.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Can CSS Grid make every tile the same size when source images have different proportions?
Yes. Give the tile a consistent size or aspect ratio and set the image’s object-fit behavior. Choose cover for filled tiles or contain to preserve the complete image.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

