No. While Google recommends we use W3C validation, Google doesn’t rank valid html and css pages above invalid pages. If Google can crawl and render a page Google will rank the page appropriately based on how relevant it is to the query.
Invalid HTML can on the other hand can cause search engines problems.
QUOTE: “In general, the W3C validation is something that we do not use when it comes to search. So you don’t need to worry if your pages kind of meet the validation bar or not. However, using the validation is a great way to double check that you’re not doing anything broken on your site.” John Mueller, Google 2020
Check any top ten results in Google and you will probably see that most contain invalid HTML or CSS. I love creating accessible websites but they are a bit of a pain to manage when you have multiple authors or developers on a site. It’s easy to let standards slip, on your own site.
QUOTE: “In general, we try to go by the guideline of looking at which pages are actually relevant for the user instead of looking at which pages are implementing any kind of specific technical markup, for example. So that goes with regards to HTML. If a page is valid HTML, then obviously that’s a good thing. But it’s not that a user is really going to notice that in most cases if it’s valid HTML or not. So we’re not going to use that as a ranking factor.” John Mueller, Google 2015
Google has also confirmed multiple times they do not use W3C standards compliance when ranking pages.
If Google can read it – it will rank it. Google was built to understand websites with low-quality code, and it’s got a lot better over the years. I have never observed a site that was inaccessible run into major ranking problems that weren’t probably caused by other more important quality factors.
QUOTE: “Well, a lot of websites can have invalid code but actually render just fine, because a lot of modern browsers do a good job dealing with bad code. And so, it’s not so much that the code has to be absolutely perfect, but whether or not the page is going to render well for the user in general.” Danny Sullivan, Google 2011
If your website is VERY badly designed with a LOT of invalid code even Google and browsers cannot read it, then you have a problem. I’ve not come across many sites in that bad a condition, recently.
QUOTE: “Broken HTML or unsupported content on your pages: If Googlebot can’t parse the content of the page, perhaps because it uses an unsupported media type or the page is only images, it won’t be able to crawl them.” Google Webmaster Guidelines, 2020
What Is Valid HTML?
HTML is the language of the web, and the W3C developed it and tells us all the correct way to use it.
Google recommends we follow W3C guidelines:
QUOTE: “Use valid HTML” Google Webmaster Guidelines, 2020
Valid code is a sign of a web developer who has a passion for web accessibility, usability and good design – with an attention to detail, and a pride in their work. A site built to standards is often easier to access using many devices. The idea is to have clean, properly marked up code. A good content-to-code ratio.
QUOTE: “Although we do recommend using valid HTML, it’s not likely to be a factor in how Google crawls and indexes your site.” Google Webmaster Guidelines 2018
Essentially what is being stated is a fairly logical conclusion: reduce the amount of code on your page and the content (you know, the place where your keywords are) takes a higher priority. Additionally compliance will, by necessity, make your site easy to crawl and, additionally, allow you greater control over which portions of your content are given more weight by the search engines. The thinking behind validating code for SEO benefits was once you have a compliant site, not only will your site be a better user experience on a much larger number of browsers, but you’ll have a site with far less code, that will rank higher on the search engines because of it.
That sounds nice, but in reality, it’s that is not how it works.
QUOTE: “As long as it can be rendered & SD extracted: validation pretty much doesn’t matter.” Google Webmaster Guidelines 2018
To be sure, W3C validation is not the “SEO magic bullet” to top rankings. There is no magic bullet. There IS an argument to take every advantage you can – to not only get to the first page, but to consolidate your position against those who want to take it from you (as you took it from someone else) but for me, making a website validate is not a priority, when it comes to Google rankings, as there are more important factors at play than page level code quality.
Where possible, if commissioning a new website, demand at least minimum accessibility compliance on a site (there are three levels of priority to meet), and aim for valid HTML and CSS. Actually, provision of web accessibility is law in the UK and in some other countries, although you would not know it, and be prepared to put a bit of work in to keep your validation badge.
QUOTE: “It makes sense to create websites that are accessible to as many people as possible. To comply with UK law you must put a little effort in to meet accessibility recommendations for websites. The W3c lay down the general guidelines for websites that most people adhere to.” Shaun Anderson, Hobo 2020
Testing If Does Google Prefers Valid HTML
Many years ago I ran a very small scale test to see if I could quickly see if Google preferred Valid HTML and VALID CSS.
It consisted of:
- 4 Pages on the hobo site
- New but Duplicate Content of Course
- All HTML pages
- All page names garbled letters to ensure no preference in Google. Will Google read the pages by alphabetical order, date created etc? Who knows – maybe we’ll find out this too.
- 1 Valid HTML + CSS
- 1 Valid HTML + Invalid CSS
- 1 Invalid HTML + Valid CSS
- 1 Invalid HTML + Invalid CSS
- Anchor Text same text so as not to influence Google (of course this isn’t good for accessibility having links to different pages using the same text phrase)
- As far as we know we’ve tried to duplicate the pages including page titles and meta-descriptions etc. What this test should also test is will Google, today at any least, collect at least one page from this duplicate content or will it ignore them all.
- We assume everything is equal apart from validation – that includes duplicate keyword descriptions, keywords and title elements etc.
- In this first test we’ll put it in a folder. This may make everything go supplemental but we can wait and SEO ;)
I was actually surprised at the results. From these 4 pages Google ranked the page with valid CSS and valid HTML top. Google spidered the pages, examined them, applied duplicate content filters as expected, and selected one to rank. It just happens that Google seems to prefer the page with valid code as lay down by the W3C (World Wide Web Consortium).
Was this evidence Google preferred Valid code at a very granular level?
Well at the time, I thought so, but I had a lot to learn about testing SEO, and in the end, I could not determine if Google just picked the most recent edited documents. It WAS the last edited document that came top, as well as it being the valid document. Plus it would have been subject to Google’s duplication filters.
I didn’t run the test again.
FYI – What is CSS?
CSS, or Cascading Style Sheets, is a ‘language’ that website designers use to develop the style, look and feel of layout, text and colours on a website page.
Used properly, CSS can be used to separate design from content, making websites easier to use and ultimately, maintain. It can also help with download times as the CSS is downloaded only once and held in browser cache.
A good (the best?) website development technique is to build your pages using HTML and link this page to what is called an external CSS file that controls all elements of style on the site. You then link the stylesheets in your like so:
- CSS means (is an acronym for) ‘Cascading Style Sheets’
- CSS Styles help define how to display HTML elements in a browser
- CSS Styles are normally stored in ‘External’ CSS Style Sheets on a site
- CSS Styles were added to HTML 4.0 by the W3c
- External Style Sheets can save website designers a lot of time and effort when updating sites – we at Hobo use them
- Multiple CSS style definitions are designed to ‘cascade’ into one
What Is CSS For?
HTML tags / elements were originally designed to define the content of a document. They were supposed to say “This is a header”, or “This is a less important header “, or “This is a paragraph “, and by using tags.
The layout of the document was supposed to be taken care of by the browser, without using any formatting tags.
Netscape and Internet Explorer continued to add new HTML tags and attributes (like the tag and the colour attribute) to the original HTML specification. It soon became more and more difficult to create Web sites where the content of HTML documents was clearly separated from the document’s presentation layout.
To solve this problem, the World Wide Web Consortium (W3C) – the non profit, standard setting consortium, responsible for standardizing HTML – created STYLES in addition to HTML 4.0.
All major browsers support Cascading Style Sheets, although some, handle them slightly differently, which an be a pain to the website designer!
Cost Effective Website Development
CSS defines how HTML elements are to be displayed. CSS Styles are normally saved in external .CSS files. External style sheets enable you to change the appearance and layout of all the pages in your Web, just by editing one single CSS document!
CSS allows website developers to control the style and layout of multiple web pages all at once. As a Web developer you can define a style for each HTML element and apply it to as many website pages as you want. To make a site-wide change, simply change the style, and all elements in the website are updated automatically.
Multiple Styles Will Cascade Into One Style
Style sheets allow style information to be specified in many ways. Styles can be specified inside a single HTML element, inside the element of an HTML page, or in an external CSS file. Even multiple external style sheets can be referenced inside a single HTML document.
Cascading Order of CSS
CSS styles will “cascade” into a style by the following rules, where number four has the highest priority:
- Browser default
- External style sheet
- Internal style sheet (inside the <head> tag)
- Inline style (inside an HTML element)
So, an inline style (inside an HTML element) has the highest priority, which means that it will override a style declared inside the <head> tag, in an external style sheet, or in a browser (a default value).
For a more complete guide to CSS – visit W3C Schools.
UK Government recommendations:
‘Use HTML to structure the document, not style it. Use Cascading Style Sheets to format and style basic elements of a website’
Guidelines for UK Government websites
Illustrated handbook for Web management teams
Valid HTML and CSS are a pillar of best practice website optimisation, not strictly search engine optimisation (SEO). It is one form of optimisation Google will not penalise you for.
QUOTE: “I have 20 years of experience practicing professional SEO. This SEO tutorial is my collection of tips and SEO best practices I use to rank websites in Google.” Shaun Anderson, Hobo 2020