Archived topic
Set an explicit width and height on image elements to reduce layout shifts
1 reply · Started by Ted on March 29, 2021
Hey,
Just running through Pagespeed Insights and I get this message: Image elements do not have explicit width and height
It refers to the logo on my site. I currently have Use Navigation as Header checked in the Header option within Customize, and do everything through Site Identity + Primary Navigation.
I dictate the logo size in Primary Navigation > Menu Item Height, which puts it at a size of 50px. But, this isn't noted in the logo image itself, which is bringing up this "Set an explicit width and height on image elements to reduce layout shifts and improve CLS" message.
Any way that I can set a width and height on the logo easily?
Thanks!
Hi there,
You can set it here for desktop:
https://docs.generatepress.com/article/generate_logo_output/#setting-a-width-and-height
And if you're using a mobile here, use this:
https://docs.generatepress.com/article/generate_mobile_header_logo_output/#setting-a-width-and-height