{"id":51717,"date":"2026-10-08T15:29:32","date_gmt":"2026-10-08T11:59:32","guid":{"rendered":"https:\/\/8899.ir\/web\/?p=51717"},"modified":"2026-10-09T11:28:00","modified_gmt":"2026-10-09T07:58:00","slug":"stp-web-20261008-srcset-en","status":"publish","type":"post","link":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/","title":{"rendered":"Responsive images with srcset: serve the right file"},"content":{"rendered":"<div class=\"stpweb_20261008-education\" dir=\"ltr\" lang=\"en\" style=\"direction: ltr; text-align: left; background: #05080d; color: #eef4fa; font-family: Tahoma,Arial,sans-serif; line-height: 2; padding: clamp(12px,3vw,24px); border-radius: 18px; overflow-wrap: anywhere;\">\n<h2 style=\"color: #f4c44e;\">Responsive images with srcset: serve the right file<\/h2>\n<div style=\"background: #0b1119; color: #eef4fa; padding: 18px; border-radius: 14px;\">\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Goal: avoid forcing a 1200-pixel image onto every phone; let srcset and sizes guide the browser to an appropriate file.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Prepare three test versions of one image at 480, 800, and 1200 pixels wide, all with the same aspect ratio.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Name the files as shown in the sample and place all three beside the test HTML file.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">After each srcset filename, write its real intrinsic width using the w descriptor; guessed numbers can cause poor choices.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Use sizes to declare that the image is about the full viewport up to 600 pixels and occupies 800 pixels on larger layouts.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Keep src as the baseline source so older browsers and fallback situations still have an image.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Set width and height to the baseline aspect ratio so space is reserved before download and layout shift is reduced.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Write alt text for the image meaning; a filename or the word \u201cimage\u201d is not a useful substitute.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Open a private window, enable Network tools, disable cache, set the viewport to 375 pixels, and reload.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Inspect the chosen filename and currentSrc in the Console. A high-density display may legitimately choose a file larger than 480 pixels.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Repeat at a 1200-pixel viewport and ensure the image stays inside its 800-pixel container; add max-width:100% in CSS.<\/p>\n<p class=\"stpweb-line\" style=\"color: #eef4fa; margin: 0 0 12px;\">Success check: valid files are selected at different widths, the aspect ratio remains stable, and the alt text communicates the purpose.<\/p>\n<h3 style=\"color: #f4c44e;\">Complete example code<\/h3>\n<pre dir=\"ltr\" style=\"direction: ltr; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; background: #111d2a; color: #e9f4ff; padding: 16px; border-radius: 10px;\"><code>&lt;img src=\"photo-800.jpg\" srcset=\"photo-480.jpg 480w, photo-800.jpg 800w, photo-1200.jpg 1200w\" sizes=\"(max-width: 600px) 100vw, 800px\" width=\"800\" height=\"533\" alt=\"A useful description\"&gt;<\/code><\/pre>\n<aside style=\"color: #d3dfec;\"><\/aside>\n<hr \/>\n<h3 style=\"color: #f4c44e;\">Official sources<\/h3>\n<ul>\n<li><a style=\"color: #70d9ff;\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Guides\/Responsive_images\" target=\"_blank\" rel=\"noopener noreferrer\">MDN \u2014 Responsive images<\/a><\/li>\n<li><a style=\"color: #70d9ff;\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Reference\/Elements\/img\" target=\"_blank\" rel=\"noopener noreferrer\">MDN \u2014 img element<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Responsive images with srcset: serve the right file Goal: avoid forcing a 1200-pixel image onto every phone; let srcset and sizes guide the browser to an appropriate file. Prepare three test versions of one image at 480, 800, and 1200 pixels wide, all with the same aspect ratio. Name the files as shown in the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":51718,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-51717","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-edu"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Responsive images with srcset: serve the right file - web design &amp; Host domain provider<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/\" \/>\n<meta property=\"og:locale\" content=\"fa_IR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Responsive images with srcset: serve the right file - web design &amp; Host domain provider\" \/>\n<meta property=\"og:description\" content=\"Responsive images with srcset: serve the right file Goal: avoid forcing a 1200-pixel image onto every phone; let srcset and sizes guide the browser to an appropriate file. Prepare three test versions of one image at 480, 800, and 1200 pixels wide, all with the same aspect ratio. Name the files as shown in the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/\" \/>\n<meta property=\"og:site_name\" content=\"web design &amp; Host domain provider\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-08T11:59:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-09T07:58:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/8899.ir\/web\/wp-content\/uploads\/2026\/10\/stpweb_20261008-srcset-en.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u0646\u0648\u0634\u062a\u0647\u200c\u0634\u062f\u0647 \u0628\u062f\u0633\u062a\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u0632\u0645\u0627\u0646 \u062a\u0642\u0631\u06cc\u0628\u06cc \u0628\u0631\u0627\u06cc \u062e\u0648\u0627\u0646\u062f\u0646\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u062f\u0642\u06cc\u0642\u0647\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/#\\\/schema\\\/person\\\/5cf790b25f5efb06e6132813f46d29ba\"},\"headline\":\"Responsive images with srcset: serve the right file\",\"datePublished\":\"2026-10-08T11:59:32+00:00\",\"dateModified\":\"2026-10-09T07:58:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/\"},\"wordCount\":250,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/#\\\/schema\\\/person\\\/5cf790b25f5efb06e6132813f46d29ba\"},\"image\":{\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/8899.ir\\\/web\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/stpweb_20261008-srcset-en.jpg\",\"articleSection\":[\"edu\"],\"inLanguage\":\"fa-IR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/\",\"url\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/\",\"name\":\"Responsive images with srcset: serve the right file - web design &amp; Host domain provider\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/8899.ir\\\/web\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/stpweb_20261008-srcset-en.jpg\",\"datePublished\":\"2026-10-08T11:59:32+00:00\",\"dateModified\":\"2026-10-09T07:58:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/#breadcrumb\"},\"inLanguage\":\"fa-IR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fa-IR\",\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/#primaryimage\",\"url\":\"https:\\\/\\\/8899.ir\\\/web\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/stpweb_20261008-srcset-en.jpg\",\"contentUrl\":\"https:\\\/\\\/8899.ir\\\/web\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/stpweb_20261008-srcset-en.jpg\",\"width\":800,\"height\":600,\"caption\":\"Responsive images with srcset: serve the right file\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/stp-web-20261008-srcset-en\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/8899.ir\\\/web\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Responsive images with srcset: serve the right file\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/#website\",\"url\":\"https:\\\/\\\/8899.ir\\\/web\\\/\",\"name\":\"www.8899.ir\",\"description\":\"siamak khanjani personal web site Web design hezarehno company\",\"publisher\":{\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/#\\\/schema\\\/person\\\/5cf790b25f5efb06e6132813f46d29ba\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/8899.ir\\\/web\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fa-IR\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/#\\\/schema\\\/person\\\/5cf790b25f5efb06e6132813f46d29ba\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fa-IR\",\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/5834774893835260090.jpg\",\"url\":\"https:\\\/\\\/8899.ir\\\/web\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/5834774893835260090.jpg\",\"contentUrl\":\"https:\\\/\\\/8899.ir\\\/web\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/5834774893835260090.jpg\",\"width\":1024,\"height\":1024,\"caption\":\"admin\"},\"logo\":{\"@id\":\"https:\\\/\\\/8899.ir\\\/web\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/5834774893835260090.jpg\"},\"sameAs\":[\"https:\\\/\\\/8899.ir\\\/web\",\"htpps:\\\/\\\/instagram.com\\\/siamakkhanjaniir\",\"https:\\\/\\\/www.linkdin.com\\\/in\\\/siamakkhanjani-ir\"],\"url\":\"https:\\\/\\\/8899.ir\\\/web\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Responsive images with srcset: serve the right file - web design &amp; Host domain provider","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:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/","og_locale":"fa_IR","og_type":"article","og_title":"Responsive images with srcset: serve the right file - web design &amp; Host domain provider","og_description":"Responsive images with srcset: serve the right file Goal: avoid forcing a 1200-pixel image onto every phone; let srcset and sizes guide the browser to an appropriate file. Prepare three test versions of one image at 480, 800, and 1200 pixels wide, all with the same aspect ratio. Name the files as shown in the [&hellip;]","og_url":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/","og_site_name":"web design &amp; Host domain provider","article_published_time":"2026-10-08T11:59:32+00:00","article_modified_time":"2026-10-09T07:58:00+00:00","og_image":[{"width":800,"height":600,"url":"https:\/\/8899.ir\/web\/wp-content\/uploads\/2026\/10\/stpweb_20261008-srcset-en.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u0646\u0648\u0634\u062a\u0647\u200c\u0634\u062f\u0647 \u0628\u062f\u0633\u062a":"admin","\u0632\u0645\u0627\u0646 \u062a\u0642\u0631\u06cc\u0628\u06cc \u0628\u0631\u0627\u06cc \u062e\u0648\u0627\u0646\u062f\u0646":"2 \u062f\u0642\u06cc\u0642\u0647"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/#article","isPartOf":{"@id":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/"},"author":{"name":"admin","@id":"https:\/\/8899.ir\/web\/#\/schema\/person\/5cf790b25f5efb06e6132813f46d29ba"},"headline":"Responsive images with srcset: serve the right file","datePublished":"2026-10-08T11:59:32+00:00","dateModified":"2026-10-09T07:58:00+00:00","mainEntityOfPage":{"@id":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/"},"wordCount":250,"commentCount":0,"publisher":{"@id":"https:\/\/8899.ir\/web\/#\/schema\/person\/5cf790b25f5efb06e6132813f46d29ba"},"image":{"@id":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/#primaryimage"},"thumbnailUrl":"https:\/\/8899.ir\/web\/wp-content\/uploads\/2026\/10\/stpweb_20261008-srcset-en.jpg","articleSection":["edu"],"inLanguage":"fa-IR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/","url":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/","name":"Responsive images with srcset: serve the right file - web design &amp; Host domain provider","isPartOf":{"@id":"https:\/\/8899.ir\/web\/#website"},"primaryImageOfPage":{"@id":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/#primaryimage"},"image":{"@id":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/#primaryimage"},"thumbnailUrl":"https:\/\/8899.ir\/web\/wp-content\/uploads\/2026\/10\/stpweb_20261008-srcset-en.jpg","datePublished":"2026-10-08T11:59:32+00:00","dateModified":"2026-10-09T07:58:00+00:00","breadcrumb":{"@id":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/#breadcrumb"},"inLanguage":"fa-IR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/"]}]},{"@type":"ImageObject","inLanguage":"fa-IR","@id":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/#primaryimage","url":"https:\/\/8899.ir\/web\/wp-content\/uploads\/2026\/10\/stpweb_20261008-srcset-en.jpg","contentUrl":"https:\/\/8899.ir\/web\/wp-content\/uploads\/2026\/10\/stpweb_20261008-srcset-en.jpg","width":800,"height":600,"caption":"Responsive images with srcset: serve the right file"},{"@type":"BreadcrumbList","@id":"https:\/\/8899.ir\/web\/stp-web-20261008-srcset-en\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/8899.ir\/web\/"},{"@type":"ListItem","position":2,"name":"Responsive images with srcset: serve the right file"}]},{"@type":"WebSite","@id":"https:\/\/8899.ir\/web\/#website","url":"https:\/\/8899.ir\/web\/","name":"www.8899.ir","description":"siamak khanjani personal web site Web design hezarehno company","publisher":{"@id":"https:\/\/8899.ir\/web\/#\/schema\/person\/5cf790b25f5efb06e6132813f46d29ba"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/8899.ir\/web\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fa-IR"},{"@type":["Person","Organization"],"@id":"https:\/\/8899.ir\/web\/#\/schema\/person\/5cf790b25f5efb06e6132813f46d29ba","name":"admin","image":{"@type":"ImageObject","inLanguage":"fa-IR","@id":"https:\/\/8899.ir\/web\/wp-content\/uploads\/2026\/09\/5834774893835260090.jpg","url":"https:\/\/8899.ir\/web\/wp-content\/uploads\/2026\/09\/5834774893835260090.jpg","contentUrl":"https:\/\/8899.ir\/web\/wp-content\/uploads\/2026\/09\/5834774893835260090.jpg","width":1024,"height":1024,"caption":"admin"},"logo":{"@id":"https:\/\/8899.ir\/web\/wp-content\/uploads\/2026\/09\/5834774893835260090.jpg"},"sameAs":["https:\/\/8899.ir\/web","htpps:\/\/instagram.com\/siamakkhanjaniir","https:\/\/www.linkdin.com\/in\/siamakkhanjani-ir"],"url":"https:\/\/8899.ir\/web\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/posts\/51717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/comments?post=51717"}],"version-history":[{"count":3,"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/posts\/51717\/revisions"}],"predecessor-version":[{"id":51738,"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/posts\/51717\/revisions\/51738"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/media\/51718"}],"wp:attachment":[{"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/media?parent=51717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/categories?post=51717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/8899.ir\/web\/wp-json\/wp\/v2\/tags?post=51717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}