Moving on to XHTML 1.1

I attempted to update the current XHTML 1.0 Transisional WordPress theme in order to comply with the XHTML 1.1 Specification. I must admit that the switch was not that difficult and it required no more than 30 minutes to complete. All the errors and inconsistencies the W3C validator threw at me have been corrected and all seem to be fine by now. Below, I have posted some information about some of the changes, which may prove helpful to the reader, whenever s/he attempts such a switch of standards.

So, start by changing the document type in the header.php file of your theme. Replace the current one with the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">

Then visit the W3C Markup Validation Service and start validating your webpages. Alternatively, you may want to add a hyperlink somewhere in your theme’s footer, which will point to a specific page on the validator’s web site, which will automatically examine the referer of the request; that is your page that needs validation. Add the following hyperlink:

<a href="">Validate XHTML</a>

If your current theme is well-made you won’t be needing major modifications.

Below there is some info about the changes that required significantly more time than others, because of the many occurencies throughout the theme and the plugins’ code.

1 – The <script> element does not have a language attribute any more, so:

<script language="Javascript" type="text/javascript">

… should become just:

<script type="text/javascript">

2 – Named anchors, like:

<a name="blah"></a>

…should become:

<a id="blah"></a>

3 – The border attribute should be removed from the <img> element.

4 – Finally, the target attribute that was frequently used inside <a> elements in order to specify the target frame is not included in the XHTML 1.1 specification. Fortunately, there is a decent workaround for this.

Instead of the:

<a [...] target="_blank" [...] </a>

… one could use some Javascript code to open the hyperlink in a new frame:

<a [...] onclick="; return false;" onkeypress="; return false;" [...] </a>

Apart from this, there is another way to pass the XHTML 1.1 validation test, even if you use the target attribute. This is because XHTML has been modularized. By default only 4 core modules are included, but one can create a very own document type definition (DTD), which may inlude the target or any other module. The new DTD can then be uploaded somewhere on the net, so that people can link to it from within their pages DOCTYPE declaration.

Moving on to XHTML 1.1 by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2007 - Some Rights Reserved

George Notaras avatar

About George Notaras

George Notaras is the editor of the G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is an enthusiast self-taught GNU/Linux system administrator. He has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora. He has also developed some open-source software projects in his spare time.