Web projects fail not because they're poorly coded, but because our clients are full of doubts about the overall goal they want to achieve. Generally speaking, clients know only how a web site should look like, not how it should work. Information architecture, usability and SEO are the big taboos for them. Clients often ask to change the visual layout of a page or to add a new feature to the web site. They give us some PSD files, a couple of documents and images and they think it's all set and ready to be launched online. But they are not aware of the implications of what they're publishing. No briefing, no analysis, no brainstorming and no planning. Therefore a web developer should be an IA expert, a usability tester and a project manager, all in one (person). Too bad.
The first thing we should do is to start coding only when our client knows exactly what he wants. For that reason, we should first concentrate our efforts on making our client aware of how a web site works and not on focusing on the visual aspects of the project. A client should know that a layout can actually be changed very easily, but it's not the same for the structure and design concept of our project.
A client should be made aware of what SEO optimization, usability and IA mean on the real web. All the implications related to these areas should be clear in the client's mind or we'll end up with creating a new Frankenstein monster, that is, a spaghetti web site.
The point is that our code is only a tool: it's a strong concept and a solid design that make a web project succeed.