Do I get layout shift if I use fraction widths and aspect ratios for my images? #13625
Unanswered
hosseinitabar
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Consider this image:
Correct me if I'm wrong, please.
The browser loads this HTML and wants to render it. It does not know the width of the
span
and based on that it can determine the width of theimg
. However, the width of the parent element is still unknown, and most of the time an inline's width is calculated based on its children.So, the parent
<span>
needs theimg
to be rendered to for its width, and theimg
needs thespan
for its width. Circular dependency.Does that cause a layout shift?
What is the best practice here?
Beta Was this translation helpful? Give feedback.
All reactions