E-commerce
October 30, 2026
Are you wondering how to master HTML image encoding to boost SEO?
The key: properly configure tags improves site speed, accessibility, and SEO.
The trap: neglecting “alt”, “srcset” attributes or error handling can penalize your ranking.
So how to master HTML image encoding to boost SEO? On the agenda:
Quels attributs
are essential for SEO?
How to choose between relative and absolute URLs for your images?
What image size and weight to prioritize for performance?
How to handle borders and display errors with JavaScript?
How does Qstomy integrate image optimization into performance tracking?
Let's go.
By following these best practices, you will reduce load times, increase your Core Web Vitals score, and enhance accessibility, three essential levers for modern SEO. Qstomy supports you at every step: it automatically detects unoptimized images, suggests fixes, and provides detailed reports to measure the impact on your organic traffic.
Summary
Which attributes are essential for SEO?
The browser needs three basic attributes: src for the URL, alt for the alt text and title which appears on hover. The alt attribute is crucial: it describes the image to search engines and accessibility. Also add loading="lazy" to defer off-screen loading, and width/height to avoid content layout shifts (CLS). For responsive rendering, srcset and sizes allow offering multiple resolutions depending on the device. By following these best practices, each image becomes an additional SEO lever. Learn more about e-commerce SEO
Additionally, ensure that the text alt is concise (approximately 125 characters) while integrating the main keyword. Search engines favor rich alternatives without keyword stuffing. Also consider adding the attribute role="img" or using aria‑label when an image carries a purely decorative message, to enhance accessibility and avoid redundancy for screen readers.

Convert over 2,000 customers on average per month with Qstomy.
The world’s 1st Shopify AI dedicated to customer conversion



Empowering 200+ e-commerce merchants
How to choose between relative and absolute URLs for your images?
An address relative indicates the path from the page that calls it, for example images/produit.jpg. It simplifies site navigation: you do not modify URLs as long as the folder structure remains identical. However, an address absolue specifies the protocol and domain, such as https://monstore.com/images/produit.jpg. It ensures the file displays even from another domain or CDN, but it becomes vulnerable during a domain name change. Prefer relative for internal elements, and absolute when an image must be shared off-site or hosted on a dedicated server.
On Shopify, use Liquid filters asset_url ou img_url to automatically generate relative paths adapted to each theme. If you host your images on a CDN, prefer absolute URLs with the CDN domain to benefit from geographic caching. URLs without a protocol (//framerusercontent.com/img.jpg) allow you to respect the same scheme (http or https) as the page, thus limiting 'mixed content' warnings.
What image size and weight to prioritize for performance?
The principle is to ne jamais agrandir a smaller image than its actual display size to avoid pixelation. Opt for a maximum width of 1200 px on product pages, and compress files to 70‑80 % JPEG quality or use the format WebP for a better weight/quality ratio. An ideal weight is between 100 kB and 200 kB for most product visuals. Always check the rendering on mobile: images must remain sharp at 2 × screen resolution (retina). A file that is too heavy slows down the First Contentful Paint and penalizes your SEO.
When the WebP format is not supported (older versions of Internet Explorer), the <picture> with a <source type="image/webp"> followed by a <img> PNG/JPEG ensures a transparent fallback. Adding the attribute decoding="async" accelerates rendering, and combining loading="lazy" with importance="low" allows deferring the download of off-screen images without impacting SEO.
How to align images with text for a professional look?
L’attribut align is deprecated; you must use CSS. Use float:left ou float:right to wrap text around the image, or better yet, a container display:flex with align-items:center. This approach keeps the HTML code clean and facilitates responsive adjustments. Remember to add margin to prevent text from sticking to the image. Thus, the layout remains consistent on desktop and mobile, which improves the user experience and, indirectly, the conversion rate. Optimizing the conversion rate
For finer alignment, CSS Grid offers an explicit grid where the image occupies a dedicated cell: grid-template-columns: auto 1fr; place the image on the left and the text on the right, while preserving the DOM order. The use of object-fit: cover; ensures the image fills its container without distortion, and media queries allow adjusting the direction (column ↔ row) based on screen width.
How to add or remove a border around an image depending on the context?
The border is defined with border: 2px solid #ccc; in CSS. You can condition it to a state: for example, .image‑error {border:none;} when an image fails to load. To hide the border in case of an error, add a class via JavaScript (see the next section) or use outline:none if you do not want a visual effect. Remember that the border takes up space; if you need to preserve height, choose box-sizing:border-box. Follow customer feedback
CSS variables (--border-color) allow dynamically changing the border color based on the theme or interaction state. For example, :hover { --border-color: #ff6600; } provides a visual effect without JavaScript. By combining transition: border-color .3s; you get a fluid border that reinforces the perception of responsiveness.
How to handle broken images with JavaScript to avoid white spaces?
Utilisez l’attribut onerror of the :
<img src="produit.jpg">tag. You can also replace the image with a generic version: this.src=’placeholder.png’;. This technique removes the border and the white space left by a missing image, offering a smooth experience. Combine it with loading="lazy" to avoid slowing down the page when a resource fails. Understanding Google Shopping ranking
A more robust approach is to attach a global listener window.addEventListener(’error’, …) that captures all image errors and replaces the source with a generic SVG. Coupled with IntersectionObserver, you only load the placeholder when it becomes visible, thus saving bandwidth and avoiding layout shifts.
Why declaring width and height attributes improves Core Web Vitals?
Define width and height prevents layout shift (CLS), one of the Core Web Vitals. The browser reserves the exact space before downloading the image, stabilizing rendering and accelerating the Largest Contentful Paint. Even if the actual size differs, the browser resizes the image without causing jumps. In practice, specify the original dimensions in pixels; CSS can then reduce the display without impacting CLS. A good CLS improves SEO and conversion rates. Google Shopping and performance
Since CSS 4, the property aspect-ratio allows you to declare the exact ratio (e.g. aspect-ratio: 4/3;) without calculating width/height. This ratio reserves space even before downloading, improving Largest Contentful Paint (LCP). Also consider pre-connecting your image CDN via <link rel="preconnect" href="https://framerusercontent.com"> to reduce initial latency.
How to leverage srcset and sizes for responsive design?
The combo srcset/sizes serves the resolution adapted to each screen. Ex: srcset="img-400.jpg 400w, img-800.jpg 800w" sizes="(max-width:600px) 100vw, 50vw"The browser selects the version closest to the available width, saving bandwidth and load time. This approach reduces Time to Interactive and sharpens mobile-first SEO. Implement it on key images (products, banners) to ensure a smooth experience on smartphones and tablets. Shopping Ads Ranking
The parameter sizes must reflect your CSS breakpoints. A typical example: sizes="(max-width: 480px) 100vw, (max-width: 1024px) 50vw, 33vw". Test rendering with Chrome's device simulator: enable 'Responsive' mode, then inspect the network to verify the browser has selected the lightest variant. A poor srcset can lead to downloading oversized images, penalizing Google's mobile-first score.
What is the best practice for image format (JPEG, PNG, WebP)?
For product photography, the JPEG compressed to 70% remains the lightest. Images with transparency or sharp text require the PNG, but avoid overly large files. The format WebP combines the best of both: it retains transparency like PNG while being almost as lightweight as JPEG. All modern browsers support it, and Shopify offers an automatic converter. Thus, you deliver the best quality with the lowest file size, benefiting SEO and speed. Wix and e‑commerce
The format AVIF is gaining ground thanks to superior compression compared to WebP, especially for photos with many details. However, its support is not yet universal; plan for a JPEG/PNG fallback. For vector icons or logos, prefer the SVG which remains sharp at any resolution and weighs only a few kilobytes. Always verify that color profiles (sRGB vs AdobeRGB) are correct to avoid hue shifts on screens.
How to quickly test your image loading speed?
Use Chrome's built-in tools: open DevTools, tab Networkfilter 'Img' and observe the response time and weight. Lighthouse, accessible via DevTools, provides a performance score and flags unoptimized images. GTmetrix and WebPageTest offer detailed audits, including 'Potential Savings'. Integrate these tests into your deployment routine to detect regressions. Continuous monitoring ensures every new image meets speed standards. Category SEO Strategy
Integrate performance tests into your CI/CD pipeline with tools like Lighthouse CI or Sitespeed.io. Each pull request will trigger a test suite that checks the average image weight and detects new regressions. In addition to Chrome DevTools, WebPageTest provides a detailed 'Waterfall' report where you can visualize the exact timing of each resource and identify image-related bottlenecks.
How does Qstomy help optimize image encoding and track SEO impact?
Qstomy, your Shopify AI assistant, automatically analyzes each of your store. It suggests a alt description, detects overly heavy images, and proposes conversion to WebP. Through the Performancetab, you can view total media weight, CORE Web Vitals, and the impact on organic traffic. Qstomy also generates a weekly report: number of optimized images, CLS improvement, and SEO ranking changes. Thus, you save time and keep SEO under control effortlessly. Google Shopping and Qstomy
Qstomy exposes a REST API that allows you to automate the verification of each new image via a webhook at every deployment. You can thus create A/B testing scenarios: compare organic traffic before and after optimizing a batch of images. The dashboard also offers real-time alerts if CLS exceeds 0.1, prompting you to quickly adjust dimensions.
What checklist before publishing your images on Shopify?
Checklist d’optimisation d’image
File name : use keywords, no spaces or special characters.
Attribut alt : clear description, including the main keyword if possible.
Dimensions : maximum width adapted to the layout, never enlarge.
Poids : < 200 kB, format WebP dès que possible.
Responsive : configure srcset + sizes, test on mobile.
FAQ
Should I keep CSS borders? Yes, but only via CSS; avoid outdated HTML attributes.
How to manage a large number of images? Use Qstomy's bulk mode: upload, analyze, and optimize all at once.
What is the impact on SEO if the alt attribute is missing? Search engines ignore the image; you lose potential traffic.
That's all for today! You now have all the keys to correctly encode your images.
Before going live, test your visuals on major devices (iOS, Android, desktop) and accessibility validators like axe-core. Purge the CDN cache so the new versions are served immediately. Finally, ensure each image has an attribute title that is relevant; even if it does not directly influence SEO, it improves the user experience on hover.

Enzo
October 30, 2026


