{"id":4358,"date":"2026-11-08T18:40:00","date_gmt":"2026-11-08T18:40:00","guid":{"rendered":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/"},"modified":"2026-11-13T05:00:05","modified_gmt":"2026-11-13T05:00:05","slug":"css-images-resize-crop-background","status":"publish","type":"post","link":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/","title":{"rendered":"CSS Images: How to Resize, Crop and Add Background Images"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">CSS works with images in two ways. It styles <code>&lt;img&gt;<\/code> elements that sit in your HTML (size, cropping, rounded corners), and it adds decorative images to any element with <code>background-image<\/code>. The three rules that fix most image problems are <code>max-width: 100%; height: auto;<\/code> so images shrink without distortion, <code>object-fit: cover<\/code> to crop an image into a fixed box, and <code>background-size: cover<\/code> for full-width banners. We ran the key examples below in headless Chrome 153 and give the sizes it measured.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"365\" src=\"https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background-screenshot-1024x365.png\" alt=\"Terminal showing measured image sizes in headless Chromium: 300x150 with max-width and height auto, 300x300 with object-fit cover, 320x180 with aspect-ratio, and the inline image gap\" class=\"wp-image-4360\" srcset=\"https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background-screenshot-1024x365.png 1024w, https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background-screenshot-300x107.png 300w, https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background-screenshot-768x274.png 768w, https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background-screenshot.png 1100w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Measured in headless Chromium: what each CSS rule does to an 800&#215;400 image<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Make images responsive without stretching them<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A photo that is 800 pixels wide will overflow a 300 pixel column on a phone. The standard fix is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>img {\n  max-width: 100%;\n  height: auto;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Both lines matter. We placed an 800 by 400 pixel image, with <code>width=\"800\" height=\"400\"<\/code> in the HTML, inside a 300 pixel wide box:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>CSS on the image<\/th><th>Rendered size<\/th><th>Result<\/th><\/tr><\/thead><tbody><tr><td><code>max-width: 100%; height: auto;<\/code><\/td><td>300 x 150<\/td><td>Scaled down, correct shape<\/td><\/tr><tr><td><code>max-width: 100%;<\/code> only<\/td><td>300 x 400<\/td><td>Distorted: the HTML height of 400 still applies<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Keep the <code>width<\/code> and <code>height<\/code> attributes in your HTML anyway. According to <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Reference\/Elements\/img\" target=\"_blank\" rel=\"noopener noreferrer\">MDN&#8217;s img reference<\/a>, they let the browser work out the aspect ratio before the image downloads and reserve the space, which prevents the page from jumping as images load. We checked this with an image that had no file loaded yet: with the attributes and <code>height: auto<\/code>, the browser already reserved a 300 x 150 space for it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Crop an image to a fixed shape with object-fit<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Product grids, team photos and blog cards often need every image to be the same size, whatever shape the original is. Setting both width and height stretches the picture. <code>object-fit<\/code> tells the browser how to fit it instead:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.card img {\n  width: 300px;\n  height: 300px;\n  object-fit: cover;\n  object-position: center;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Our 800 by 400 image rendered as a 300 by 300 square, filled edge to edge with the sides cut off. The values, as <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/object-fit\" target=\"_blank\" rel=\"noopener noreferrer\">MDN describes them<\/a>:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Value<\/th><th>What happens<\/th><\/tr><\/thead><tbody><tr><td><code>fill<\/code> (default)<\/td><td>Stretched to fill the box; the shape may distort<\/td><\/tr><tr><td><code>cover<\/code><\/td><td>Fills the box, keeps its shape, and is clipped to fit<\/td><\/tr><tr><td><code>contain<\/code><\/td><td>The whole image is visible, with empty bands (&#8220;letterboxed&#8221;) if the shapes differ<\/td><\/tr><tr><td><code>none<\/code><\/td><td>Shown at its natural size<\/td><\/tr><tr><td><code>scale-down<\/code><\/td><td>Whichever of <code>none<\/code> or <code>contain<\/code> gives the smaller image<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><code>object-position<\/code> chooses which part stays visible when the image is cropped. Its default is <code>50% 50%<\/code>, the centre. Use <code>object-position: top<\/code> for portraits, so heads are not cut off.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Fixed shape, flexible width: aspect-ratio<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If the width should follow the layout but the shape should stay fixed, combine <code>aspect-ratio<\/code> with <code>object-fit<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.hero img {\n  width: 100%;\n  aspect-ratio: 16 \/ 9;\n  height: auto;\n  object-fit: cover;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In a 320 pixel container the image came out at 320 x 180, exactly 16:9, although the file itself is 2:1.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Background images<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>background-image<\/code> for decoration: banners behind a heading, patterns, textures. A full-width banner looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.banner {\n  min-height: 320px;\n  background-image: url(\"\/images\/banner.jpg\");\n  background-size: cover;\n  background-position: center;\n  background-repeat: no-repeat;\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>background-size: cover<\/code> scales the image, keeping its shape, until it covers the whole element; the overflow is cropped. <code>contain<\/code> scales it as large as possible without cropping, which can leave gaps. Both are defined on MDN&#8217;s <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/background-size\" target=\"_blank\" rel=\"noopener noreferrer\">background-size<\/a> page.<\/li>\n\n\n\n<li>The path in <code>url()<\/code> is relative to the CSS file, not to the HTML page. If the image works in the page but not in your stylesheet, this is usually why.<\/li>\n\n\n\n<li>An element with only a background image has no height of its own, so give it content, padding or a <code>min-height<\/code>.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Do not put meaningful pictures in the background. <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/background-image\" target=\"_blank\" rel=\"noopener noreferrer\">MDN warns<\/a> that browsers give assistive technology no information about background images, so a screen reader will not announce them. Product photos, charts and anything with text belong in an <code>&lt;img&gt;<\/code> with alt text.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sharp backgrounds on high-resolution screens<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/image\/image-set\" target=\"_blank\" rel=\"noopener noreferrer\"><code>image-set()<\/code><\/a> lets the browser pick the best file for the screen, and MDN lists it as widely available:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.banner {\n  background-image: image-set(\n    url(\"banner.jpg\") 1x,\n    url(\"banner@2x.jpg\") 2x\n  );\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also offer formats with <code>type()<\/code>, for example an AVIF file with a JPEG fallback. Chrome accepted both forms in our test.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Fix the small gap under images<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Images are inline elements by default, and MDN explains that the bottom of an inline image sits on the text baseline. The space below the baseline, meant for letters like &#8220;g&#8221; and &#8220;y&#8221;, shows up as a gap. In our test, a box holding a 150 pixel tall image measured 154 pixels with a 16 pixel font. Adding one line fixed it, and the box measured exactly 150:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>img {\n  display: block;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Quick reference<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>You want to<\/th><th>CSS<\/th><\/tr><\/thead><tbody><tr><td>Shrink images to fit the screen<\/td><td><code>max-width: 100%; height: auto;<\/code><\/td><\/tr><tr><td>Crop to a square or card<\/td><td><code>width<\/code> and <code>height<\/code> plus <code>object-fit: cover;<\/code><\/td><\/tr><tr><td>Keep a fixed shape at any width<\/td><td><code>aspect-ratio: 16 \/ 9; object-fit: cover;<\/code><\/td><\/tr><tr><td>Round avatar<\/td><td>A square image plus <code>border-radius: 50%;<\/code><\/td><\/tr><tr><td>Full-width banner<\/td><td><code>background-size: cover; background-position: center;<\/code><\/td><\/tr><tr><td>Remove the gap below an image<\/td><td><code>display: block;<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">CSS resizing only changes how an image is displayed, not the file the visitor downloads. A 4 MB photo shown at 300 pixels still costs 4 MB, so resize and compress images before you upload them. If you are new to stylesheets, our KB article on <a href=\"https:\/\/www.ucartz.com\/clients\/knowledgebase\/814\/Inline-Internal-and-External-CSS-How-to-Link-a-style.css-File-to-HTML-with-Examples.html\">inline, internal and external CSS<\/a> explains where these rules go, and when your site is ready to go live, our <a href=\"https:\/\/www.ucartz.com\/linux-webhosting\">shared web hosting<\/a> includes free SSL and NVMe storage.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Style images with CSS: responsive sizing without distortion, cropping with object-fit, aspect-ratio, background images, image-set() and the gap fix.<\/p>\n","protected":false},"author":5,"featured_media":4359,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[400,83],"tags":[1215,1213,1214,958,1211,1216,1212,1217],"class_list":["post-4358","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-website-development","tag-aspect-ratio","tag-background-image","tag-background-size","tag-css","tag-css-images","tag-image-set","tag-object-fit","tag-responsive-images"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CSS Images: Resize, Crop and Background Images | Ucartz<\/title>\n<meta name=\"description\" content=\"Style images with CSS: responsive sizing without distortion, cropping with object-fit, aspect-ratio, background images, image-set() and the gap fix.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"| Ucartz Blog | Ucartz\" \/>\n<meta property=\"og:description\" content=\"Style images with CSS: responsive sizing without distortion, cropping with object-fit, aspect-ratio, background images, image-set() and the gap fix.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/\" \/>\n<meta property=\"og:site_name\" content=\"Ucartz Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/UcartzOnline\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-08T18:40:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-13T05:00:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ashily Shaji\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"| Ucartz Blog | Ucartz\" \/>\n<meta name=\"twitter:creator\" content=\"@ucartz\" \/>\n<meta name=\"twitter:site\" content=\"@ucartz\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashily Shaji\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@context\":\"https:\\\/\\\/schema.org\",\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/\"},\"author\":{\"name\":\"Ashily Shaji\",\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/#\\\/schema\\\/person\\\/ed6b098cc94c224512e124471f674d69\"},\"headline\":\"CSS Images: How to Resize, Crop and Add Background Images\",\"datePublished\":\"2026-11-08T18:40:00+00:00\",\"dateModified\":\"2026-11-13T05:00:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/\"},\"wordCount\":769,\"publisher\":{\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/css-images-resize-crop-background.jpg\",\"keywords\":[\"aspect-ratio\",\"background-image\",\"background-size\",\"css\",\"css images\",\"image-set\",\"object-fit\",\"responsive images\"],\"articleSection\":[\"Tutorials\",\"Website Development\"],\"inLanguage\":\"en-US\"},{\"@context\":\"https:\\\/\\\/schema.org\",\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/\",\"url\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/\",\"name\":\"| Ucartz Blog | Ucartz\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/css-images-resize-crop-background.jpg\",\"datePublished\":\"2026-11-08T18:40:00+00:00\",\"dateModified\":\"2026-11-13T05:00:05+00:00\",\"description\":\"Style images with CSS: responsive sizing without distortion, cropping with object-fit, aspect-ratio, background images, image-set() and the gap fix.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/\"]}]},{\"@context\":\"https:\\\/\\\/schema.org\",\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/css-images-resize-crop-background.jpg\",\"contentUrl\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/css-images-resize-crop-background.jpg\",\"width\":1200,\"height\":630,\"caption\":\"CSS Images: How to Resize, Crop and Add Background Images\"},{\"@context\":\"https:\\\/\\\/schema.org\",\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/css-images-resize-crop-background\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS Images: How to Resize, Crop and Add Background Images\"}]},{\"@context\":\"https:\\\/\\\/schema.org\",\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/\",\"name\":\"Ucartz Blog\",\"description\":\"Guides on hosting, servers, streaming and automation\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/#organization\"},\"alternateName\":\"Ucartz\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@context\":\"https:\\\/\\\/schema.org\",\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/#organization\",\"name\":\"Ucartz Online Private Limited\",\"alternateName\":\"Ucartz\",\"url\":\"https:\\\/\\\/www.ucartz.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.ucartz.com\\\/assets\\\/images\\\/brand\\\/logo\\\/ucartz-logo-888x240.png\",\"contentUrl\":\"https:\\\/\\\/www.ucartz.com\\\/assets\\\/images\\\/brand\\\/logo\\\/ucartz-logo-888x240.png\",\"width\":888,\"height\":240,\"caption\":\"Ucartz\"},\"image\":{\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/UcartzOnline\",\"https:\\\/\\\/twitter.com\\\/ucartz\",\"https:\\\/\\\/www.instagram.com\\\/ucartz_com\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/ucartzonline\",\"https:\\\/\\\/github.com\\\/ucartz\",\"https:\\\/\\\/n8n.io\\\/creators\\\/ucartz\\\/\",\"https:\\\/\\\/marketplace.whmcs.com\\\/group\\\/Ucartz\"]},{\"@context\":\"https:\\\/\\\/schema.org\",\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/#\\\/schema\\\/person\\\/ed6b098cc94c224512e124471f674d69\",\"name\":\"Ashily Shaji\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/wp-content\\\/themes\\\/ucartz-blog\\\/assets\\\/images\\\/authors\\\/ashily-112.webp\",\"url\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/wp-content\\\/themes\\\/ucartz-blog\\\/assets\\\/images\\\/authors\\\/ashily-112.webp\",\"contentUrl\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/wp-content\\\/themes\\\/ucartz-blog\\\/assets\\\/images\\\/authors\\\/ashily-112.webp\",\"caption\":\"Ashily Shaji\"},\"sameAs\":[\"https:\\\/\\\/www.ucartz.com\\\/\"],\"url\":\"https:\\\/\\\/www.ucartz.com\\\/blog\\\/author\\\/ashily\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CSS Images: Resize, Crop and Background Images | Ucartz","description":"Style images with CSS: responsive sizing without distortion, cropping with object-fit, aspect-ratio, background images, image-set() and the gap fix.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/","og_locale":"en_US","og_type":"article","og_title":"| Ucartz Blog | Ucartz","og_description":"Style images with CSS: responsive sizing without distortion, cropping with object-fit, aspect-ratio, background images, image-set() and the gap fix.","og_url":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/","og_site_name":"Ucartz Blog","article_publisher":"https:\/\/www.facebook.com\/UcartzOnline","article_published_time":"2026-11-08T18:40:00+00:00","article_modified_time":"2026-11-13T05:00:05+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background.jpg","type":"image\/jpeg"}],"author":"Ashily Shaji","twitter_card":"summary_large_image","twitter_title":"| Ucartz Blog | Ucartz","twitter_creator":"@ucartz","twitter_site":"@ucartz","twitter_misc":{"Written by":"Ashily Shaji","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@context":"https:\/\/schema.org","@type":"Article","@id":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/#article","isPartOf":{"@id":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/"},"author":{"name":"Ashily Shaji","@id":"https:\/\/www.ucartz.com\/blog\/#\/schema\/person\/ed6b098cc94c224512e124471f674d69"},"headline":"CSS Images: How to Resize, Crop and Add Background Images","datePublished":"2026-11-08T18:40:00+00:00","dateModified":"2026-11-13T05:00:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/"},"wordCount":769,"publisher":{"@id":"https:\/\/www.ucartz.com\/#organization"},"image":{"@id":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/#primaryimage"},"thumbnailUrl":"https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background.jpg","keywords":["aspect-ratio","background-image","background-size","css","css images","image-set","object-fit","responsive images"],"articleSection":["Tutorials","Website Development"],"inLanguage":"en-US"},{"@context":"https:\/\/schema.org","@type":"WebPage","@id":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/","url":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/","name":"| Ucartz Blog | Ucartz","isPartOf":{"@id":"https:\/\/www.ucartz.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/#primaryimage"},"image":{"@id":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/#primaryimage"},"thumbnailUrl":"https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background.jpg","datePublished":"2026-11-08T18:40:00+00:00","dateModified":"2026-11-13T05:00:05+00:00","description":"Style images with CSS: responsive sizing without distortion, cropping with object-fit, aspect-ratio, background images, image-set() and the gap fix.","breadcrumb":{"@id":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/"]}]},{"@context":"https:\/\/schema.org","@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/#primaryimage","url":"https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background.jpg","contentUrl":"https:\/\/www.ucartz.com\/blog\/wp-content\/uploads\/2026\/11\/css-images-resize-crop-background.jpg","width":1200,"height":630,"caption":"CSS Images: How to Resize, Crop and Add Background Images"},{"@context":"https:\/\/schema.org","@type":"BreadcrumbList","@id":"https:\/\/www.ucartz.com\/blog\/css-images-resize-crop-background\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.ucartz.com\/blog\/"},{"@type":"ListItem","position":2,"name":"CSS Images: How to Resize, Crop and Add Background Images"}]},{"@context":"https:\/\/schema.org","@type":"WebSite","@id":"https:\/\/www.ucartz.com\/blog\/#website","url":"https:\/\/www.ucartz.com\/blog\/","name":"Ucartz Blog","description":"Guides on hosting, servers, streaming and automation","publisher":{"@id":"https:\/\/www.ucartz.com\/#organization"},"alternateName":"Ucartz","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.ucartz.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@context":"https:\/\/schema.org","@type":"Organization","@id":"https:\/\/www.ucartz.com\/#organization","name":"Ucartz Online Private Limited","alternateName":"Ucartz","url":"https:\/\/www.ucartz.com\/","logo":{"@type":"ImageObject","@id":"https:\/\/www.ucartz.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.ucartz.com\/assets\/images\/brand\/logo\/ucartz-logo-888x240.png","contentUrl":"https:\/\/www.ucartz.com\/assets\/images\/brand\/logo\/ucartz-logo-888x240.png","width":888,"height":240,"caption":"Ucartz"},"image":{"@id":"https:\/\/www.ucartz.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/UcartzOnline","https:\/\/twitter.com\/ucartz","https:\/\/www.instagram.com\/ucartz_com","https:\/\/www.linkedin.com\/company\/ucartzonline","https:\/\/github.com\/ucartz","https:\/\/n8n.io\/creators\/ucartz\/","https:\/\/marketplace.whmcs.com\/group\/Ucartz"]},{"@context":"https:\/\/schema.org","@type":"Person","@id":"https:\/\/www.ucartz.com\/blog\/#\/schema\/person\/ed6b098cc94c224512e124471f674d69","name":"Ashily Shaji","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.ucartz.com\/blog\/wp-content\/themes\/ucartz-blog\/assets\/images\/authors\/ashily-112.webp","url":"https:\/\/www.ucartz.com\/blog\/wp-content\/themes\/ucartz-blog\/assets\/images\/authors\/ashily-112.webp","contentUrl":"https:\/\/www.ucartz.com\/blog\/wp-content\/themes\/ucartz-blog\/assets\/images\/authors\/ashily-112.webp","caption":"Ashily Shaji"},"sameAs":["https:\/\/www.ucartz.com\/"],"url":"https:\/\/www.ucartz.com\/blog\/author\/ashily\/"}]}},"_links":{"self":[{"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/posts\/4358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/comments?post=4358"}],"version-history":[{"count":1,"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/posts\/4358\/revisions"}],"predecessor-version":[{"id":4361,"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/posts\/4358\/revisions\/4361"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/media\/4359"}],"wp:attachment":[{"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/media?parent=4358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/categories?post=4358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ucartz.com\/blog\/wp-json\/wp\/v2\/tags?post=4358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}