Jump to content

W3C Jigsaw fails on invalid CSS

Go to solution Solved by Lesum,

Recommended Posts

Posted

I've been running a variety of site analytics tools against my site, https://poochkingdom.com, and I've noticed a lot of validations are failing on invalid CSS that's provided in the templates. I wanted to double-check the issues using the W3C Jigsaw tool, and after a bit of head scratching about parse errors, I realized that some of the CSS selectors are incorrect when it comes to media directives.

Question 1: If I understand correctly, shouldn't the "@media" block be outside of the selector? Should I open a bug for this or will browsers ignore the error?

.fe-block-yui_3_17_2_1_1718560167175_52219 {
    grid-area: 25/3/30/9;
    z-index: 5;
    @media (max-width: 767px) {
    }
}

Question 2: I've seen some CSS shared on the forums using "@media" and borrowed some for my site. Jigsaw is saying the syntax is incorrect until I add the 'only' qualifier. Is this because Jigsaw is out of date, or because this syntax is out of date? I haven't found a definitive answer online.

Parse error @media screen and (max-width: 575px) ....

Parse ok  @media only screen and (max-width: 575px) ....

Thanks in advance.

  • Replies 3
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution
Posted

Hi @PoochKingdom,

Question 1: You are correct. The @media directive should not be nested inside a CSS selector. Most modern browsers are quite forgiving with minor syntax errors. However, to ensure cross-browser compatibility, it's best to follow the correct syntax. Opening a bug report might be a good idea to get this issue addressed.

Question 2: The syntax without only is valid and widely supported by modern browsers. Using only in @media is mainly to hide styles from older browsers that don’t support media queries.  The W3C Jigsaw tool might be strict or outdated in its parsing rules. 

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Posted

FYI @Lesum, support were particularly uninterested in opening a bug for this. The support representatives (multiple) were hung up on the fact that the invalid "@media" directive was discovered using tools like W3C Jigsaw. The general sentiment appears to be, "Squarespace is a CMS, so tools like this can't be trusted to give accurate results. Consequently, we're not going to investigate or open a case." They even went as far as saying that they had no escalation path for a report like this, so they take it that engineering are not interested in having them reported 🤷‍♂️

Even including the offending CSS snippet in my emails did not convince them. I guess that reporting bugs is passé.

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.