A Work in Progress

developer's blog by Wei
lots of work in progress notes
TimelineCredits

Google Says My Site Not Mobile Friendly Because Content Wider than Screen

October 08, 2019

A while ago I ran into a problem where the last padding of my horizontal scrolling gallery does not display. I discussed my solutions with my friend Huijing, who then dived deeper into this issue and wrote an entertaining article about this.

As you can see from this image taken from Huijing's demo of the problem, the last padding to the right of the last image is not showing up.

demo from Huijing's article, the last padding to the right of the last image does not display

So the pseudo element solution she discussed in the article was how I initially solved the problem. In a simple screenshot, the solution looks like this:

append a pseudo element to the last element of the list

For your reference to play around with this, I copied Huijing's demo to a glitch project that extracts this solution for easier inspection, sorry Codepen 🙈.

Today, however, I received an issue ticket regarding this. Apparently Google SEO is not happy with that pseudo element. At least during the "mobile friendly test", it's complaining that "content wider than screen".

How does Google even figure out about that pseudo element? I've played around a little bit and realize that as long as I render that pseudo-element, even if I set its width to 0, it is still breaking the mobile friendly test.

Fun another fact: both me and Kenrick was then recognized as bots by Google because we were punching our test cases in the Mobile Friendly Test too frequently, and it gave us captchas.

pseudo element solution breaking Google's SEO mobile friendly test

Honestly, we haven't figured out the magic behind Google's SEO. The most relevant information I found on this topic is the Content Sized Correctly for Viewport audit, but our case actually passes the relevant test case mentioned in the info sheet, i.e., window.innerWidth === window.outerWidth. Maybe we should go to the next Google Dance and have some opinions about this?

Eventually, we decided that we'll go with the border solution, the other solution that Huijing mentions in her article, where you render a transparent border. She mentions an issue regarding scroll bars, as in you can't style them for windows browsers. Together with our special UI requirement, we added the border right to the last item instead.

The fact that border does and a zero width pseudo-element does not pass the audit by the name "content wider than screen" is still beyond my comprehension. Someone in the room is drunk.

rendering a border of lightgoldenrodyellow to the last child

Oh and speaking of scroll bars, you absolutely have to read this amazing article Two Browsers Walked into a Scrollbar.

A morning of my youth, ¯\_(ツ)_/¯

Related links