Emoji issue when rendering on webkit - Issue with how HTML is rendered

That’s because all the standardized unicode emoji are meant to fit into a square, and we assume sites want their emoji to be sized consistently in a way that works alongside text and other emoji :teapot: if that teapot was 50x50 it would put a huge gap between lines like this:

Screenshot 2023-03-13 at 5.36.36 PM

There’s a good explanation from when it was originally added:

With supporting details from Multimedia: Images - Learn web development | MDN

When the width and height attributes of an image are included on an HTML <img> element, the aspect ratio of the image can be calculated by the browser prior to the image being loaded. This aspect ratio is used to reserve the space needed to display the image, reducing or even preventing a layout shift when the image is downloaded and painted to the screen. Reducing layout shift is a major component of good user experience and web performance.

While developer best practices from the last decade may have recommended omitting the width and height attributes of an image on an HTML <img>, due to aspect ratio mapping, including these two attributes is considered a developer best practice.

All that said, you’ve got a reasonable example of a case where the default sizing won’t work for all emoji… that old cheers emoji is 3x as wide, so it doesn’t fit nicely in a square. It’s not unusual for other apps to limit all emoji to squares so we’re not too unusual in our behavior here (both Slack and Discord do it, for example)… but alternatively we could considering allowing custom emoji to optionally have dimensions set.

2 Likes