HTML & CSS · Middle · Question 19 of 75

Which technique best prevents layout shifts caused by loading images?

Explanation

Knowing the proportions, the browser reserves space before the file loads, so content doesn't jump. Modern browsers compute aspect-ratio from the width/height attributes automatically. Lazy loading without dimensions makes shifts worse, and loading via JS hurts LCP.

Further reading

Problem with a question

HTML & CSS · Middle · question 19

Test yourself

Take the HTML & CSS · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz