Web site code optimisation

Does valid code matter?

You often see that question on SEO forums, and the wide diversity of replies shows how much confusion there is on this. It usually degenerates pretty quickly into an argument between those who fervently believe valid code helps search rankings and those who don’t. This misses the point completely.

My opinion, confirmed by numerous examples of building sites that rank quickly and well, is that code should certainly be as valid as possible but that more importantly it should be elegant and it should be suitable.

What exactly do I mean by elegant? Einstein said that things should be as simple as possible but no simpler. Really well structured code is so simple that it can read almost as easily in the browser source code as it can when it’s rendered. That is the result of good planning at the design stage – not rigid planning that goes for a specific effect but flexible planning that can allow for changes requested by clients and future development of the site.

By suitable I mean coding and programming that has been designed to accomplish the tasks that the site requires while fitting in with the overall design. Not something that has been borrowed from other sites and which then needs hacks and inline styles to fit in.

Read your source code and if you see complexity ask yourself why it’s there and is it necessary.

It’s very rare that you need to have code that has classes or span tags on every paragraph or heading – they should inherit their styling from their parent elements. It’s extremely rare that you need to use tables for anything other than tabular data.

Complex dynamic sites provide plenty of opportunity to go wrong because very often such a site’s different modules will be built by different programmers, and if no-one has an overall vision for the site and controls the architecture of it you’ll often find that parts of its coding structure are derived programmatically using inline tricks which produce poor HTML. Being a good programmer doesn’t mean being a good web designer and if there are multiple people working on a site there needs to be good communications between them.

This is also where the SEO knowledge has to come in if it hasn’t already, because it’s rare for programmers to have any understanding of it. That’s not to criticise them – they only require it if they are taking on a wider role than just programming.

When validity matters

Note that since the second paragraph I haven’t mentioned validity at all, let alone as a goal in itself. Elegant code will nearly always be valid pretty much automatically. However code can be valid and not elegant. It’s perfectly possible to write complex and convoluted code that is perfectly valid but not at all appropriate.

There are many different types of errors that can cause invalid code. Some are of very little importance, some may be important for cross-browser compatibility purposes but not be show stoppers otherwise, while others may be fundamentally important to HTML structure. Search engines may well be able to ignore many of the less important errors but may be unable to interpret the more structural ones. For instance I have seen cases where crucially placed duplicate IDs have caused spiders not to follow navigation systems. One site appeared perfectly ok in all other aspects and no-one could understand why it wasn’t being properly indexed until I pointed out this problem and corrected it; whereupon the missing pages suddenly began to appear in the indexes.

You won’t get prizes from the search engines for just having valid code but you will get benefits from well-designed, simple and elegant code; and that’s what you should be aiming for as both a web designer and an SEO.

Comments are closed.