Previously, we discussed the importance of W3C validation and SEO and shown examples of our websites of both errors, validated and errors which can be corrected. This time we will discuss on making your WordPress website W3C validated; well you might end up with 12 errors; but it is much better than your 80 error for sure.
To comply with W3C standards for your WordPress website, you must take into account several parameters:
Declaring a doctype
This declaration is found in thefile in WordPress. The doctype is the first line of your HTML page, this declaration allows us to know the search bots how HTML is has been used. If you declare a W3C doctype, it must conform to the specifications of the latter, if in doubt about using the code, only the official documents are authentic.
The three statements most used at present are(this language is officially abandoned, but read our note later), and (replacing the HTML4 and XHTML).
Here is our doctoype:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” dir=”ltr” lang=”en-US”>
We were saying before to read note later, the note is that, if you see in W3C validation that, declaration as Transitional generating less error or even validating it than your native Strict (you can force in W3C tool like the below screenshot), simply go to Theme editor and change it.
This is not cheating or any fraud method, it is the Theme creator (or other plugins and gadgets you use) who have used a mixed up code. As you can guess from the name, Strict is strict and Transitional allows older HTML codes like target=”_blank”. It is almost an impossible work (for non developers like me) to make and mantain WordPress doctype Strict, because WordPress itself adds those old codes from the writing panel.
The presentation of content with style sheets (CSS)
This is important. Each HTML page containing texts and images is attached one or more cascading style sheets (or CSS). The stylesheet also follows strict recommendations. Follow these recommendations can be assured that the site displays correctly on all browsers. This can be checked from W3C CSS validation.Advertisement
Though it seems very tough job, practically there is easy way for relatively noob user on programming side. It is thefile in your theme that mainly we will think of. This is why simple coded theme platform such as Thesis platform or Genesis works great. They have mainly one CSS file plus only the Child theme’s stylesheet will be used practically. So, if you can code or modify any child theme, it will have less error.
In any case, copy the full Stylesheet after opening in Notepad or any Text Editor and clean up using Clean CSS. Those are regular reader of this website knows that we written ago about how to install WordPress offline for testing. Use that installation for testing the new corrected CSS. Do not change the header part of CSS file that says the name of the Theme, otherwise it will be a mess.
Architecture and Semantic HTML
Here is needed reference of 500 pages written by W3C, we can feel the thing that are coming in your mind if you are not a developer. Just scan it if you can understand things a bit on the first look. Necessity is the mother of not of only invention but also understanding! When you will understand tweaking in their way helping your website, you will be interested to understand.
Understanding the W3C validation report and correcting your WordPress website
This is difficult to do for CMS platform like WordPress. This is how we have corrected our other website:
- Understand why the validation tool is marking a red mark. Search for it.
- Your theme, without any plugin, gadgets should be by default valid. Otherwise you will get mad but can not correct anything. It is something like trying to straighten a dog’s tail. Before buying go to the demo page; copy paste the url to W3C validator to check. This is not fool proof due to several reasons, but a theme with 80 errors should make you thoughtful.
- Yahoo site meta tag will caught by validation tool as error (so three errors corrected). Simply remove it after few weeks after validation or upload HTML file to your root.
- Do not copy paste Facebook code from Facebook developer API. Use some facebook plugin (two or three errors corrected).
- Some Advertisers have incorrect / invalid code : so it is question of compromise.
- Use xHTML compliant codes (tracking for example) instead of default codes; they offer such option too.
- Plugins: You have to identify which plugins are pumping invalid codes. Remove them.