View Full Version : [How-to] Make Your vB Template XHTML Validate Correctly

13 Sep 2007, 17:31
Have you tried validating your vBulletin-powered site with the W3C validator (http://validator.w3.org)? A standard vB installation will fail the validation with one error-- it's missing the xmlns attribute for html tag at the very beginning. You can check this by validating the vB forums (http://validator.w3.org/check?uri=www.vbulletin.com%2Fforum).

The <html> tag should look like <html xmlns="http://www.w3.org/1999/xhtml">

So until vB's default templates are changed to include the xmlns info, I needed a workaround, and I didn't want to manually edti dozens of templates.

In comes a brilliant feature that is implemented in the ACP. Expand the Styles & Templates section and click on Replacement Variable Manager.

Add a new Replacement Variable for each of your parent styles.

Search for text:
Replace with text:
<html xmlns="http://www.w3.org/1999/xhtml"
This will add the xmlns attribute to the <html> tag and now your pages should validate as XHTML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" lang="en">Turns into

<!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">
Happy Validating! :)

21 Oct 2007, 17:17
thanks dood!

27 Oct 2007, 01:47
Awesome, cheers! ;)

14 Nov 2007, 06:47
realy awesome :)

19 Dec 2007, 12:30
You can check this by validating the vB forums (http://validator.w3.org/check?uri=www.vbulletin.com%2Fforum).

With the new vB release, it should be corrected. If you check now that link, it say is Valid XHTML 1.0 Transitional.

19 Dec 2007, 13:11
I wanted to say the same thing about 2 hours ago Triky... but then i looked at the thread date and i said to myself: "Naaaaaaaaaaaah".

19 Dec 2007, 14:25
LOL http://www.web-city.it/forum/images/smilies/asd.gif

21 Dec 2007, 18:37
I have 2175 errors

how can I fix it ?


18 Feb 2008, 13:21
The fix suggested by Analogpoint has the downside of making all templates showing up as modified.

Another fix for making vBulletin 3.6.x validate is to hack the includes/functions.php file.
Line 4628 (or somewhere around there) should read:
$stylevar['textdirection'] = 'ltr';

Replace that with
$stylevar['textdirection'] = 'ltr" xmlns="http://www.w3.org/1999/xhtml';

and you will have xmlns="http://www.w3.org/1999/xhtml'; inserted in the right place in your <html>-tag.

My suggestion for a fix is much uglier but it has the benefit that it can be undone very easily and doesnt make all your templates show up as modified.

After doing some testing I realised that that variable is also used in some of the templates. So there will still be template edits. Hopefully not as many though.