CSS 有效性会影响 SEO 吗?

Does CSS validity affect SEO?

很多前端开发者都知道有效HTML对SEO有积极的影响。但是有效的 CSS 会影响 SEO 吗?

在 Google 网站的 https://support.google.com/webmasters/answer/100782?hl=en 页面上显示:"Clean, valid HTML is a good insurance policy, and using CSS separates presentation from content, and can help pages render and load faster. Validation tools, such as the free online HTML and CSS validators provided by the W3 Consortium, are useful for checking your site, and tools such as HTML Tidy can help you quickly and easily clean up your code."

但是如果你看看世界上最流行的前端组件库,你会发现即使它包含很多来自 W3C 验证程序的错误和警告。

:root{
    --blue:#007bff;
    --indigo:#6610f2;
    --purple:#6f42c1;
    --pink:#e83e8c;
    --red:#dc3545;
    --orange:#fd7e14;
    --yellow:#ffc107;
    --green:#28a745;
    --teal:#20c997;
    --cyan:#17a2b8;
    --white:#fff;
    --gray:#6c757d;
    --gray-dark:#343a40;
    --primary:#007bff;
    --secondary:#6c757d;
    --success:#28a745;
    --info:#17a2b8;
    --warning:#ffc107;
    --danger:#dc3545;
    --light:#f8f9fa;
    --dark:#343a40;
    --breakpoint-xs:0;
    --breakpoint-sm:576px;
    --breakpoint-md:768px;
    --breakpoint-lg:992px;
    --breakpoint-xl:1200px;
    --font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    --font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace
} ... <= This is just a small part of the file bootstrap.min.css.

验证器 https://jigsaw.w3.org/css-validator/ 说 Bootstrap 中有 30 个错误和 670 个警告。但是这个 CSS 被许多成功的网站使用。如果他们使用有效的 CSS,他们在 SEO 中会更成功吗?

browser compatibility 的一般指南中,Google 提到了 W3C 验证工具以编写良好、干净的代码。

他们还声明如下:

Although we do recommend using valid HTML, it's not likely to be a factor in how Google crawls and indexes your site.

因此我们可以假设 CSS 也是如此。

请记住,您的 CSS 中还有很多其他因素会影响搜索排名,例如适合移动设备的样式,以及导致加载时间变慢的因素,例如选择器特异性、文件大小、进口等