According to DEV Community, a common annoyance on article pages is text that moves while someone is reading. A reader starts the paragraph under a photo, the photo finishes loading, takes up its height and pushes the text down. The article says the browser could have reserved that space from the start if the markup had given it the proportions of the file.
The fix is to state the photo's dimensions on the img element. The example uses a file called escalier.jpg that measures 1,200 by 800 pixels. You enter those values on the element, then use CSS to let the width follow the column. In a 360-pixel column, the browser can then hold back 240 pixels of height before the file arrives. On a wide screen, the photo grows with its column. The article points to the images chapter of the web.dev guide for the calculation and its effect on layout shifts, which are the unexpected movements of content on a page.
To check the result, the article suggests opening the browser developer tools, slowing the network and turning off the cache for the test. Reload the page and watch the text under the photo. In the 360-pixel example, the reserved height stayed at 240 pixels and the text did not move. With the dimensions left out, the same photo shifted the text by 219 pixels. To repeat the measurement, compare the text position before and after the file loads.
The last point concerns srcset, the attribute that lets a page offer several versions of one image at different sizes. If it offers files 600 and 1,200 pixels wide, the article says to export them at 600 by 400 and 1,200 by 800 so the ratio stays the same. A version cropped to a square for mobile needs a different ratio. The article advises testing that crop on a narrow screen so the reserved space matches the file the browser actually picks.
Why it matters
Text that jumps while a page loads is irritating for readers, and it can cause a misclick or a lost place in the article. The fix described here is small. It needs the right numbers in the markup and a CSS rule, not a redesign.
The slowed-network test is useful because most people check pages on a fast connection with a warm cache, where the problem hides. Checking cropped variants matters too. A mismatch between the reserved space and the chosen file can bring the problem back on phones.
Source: DEV Community. This brief summarises their reporting; read the original for the full detail.