• Hi,

    I’ve come across something that I can’t find an answer to anywhere else on the web. Feel free to have a look at the website here – h t t p : / / w w w . s o h a i l t e c h . c o m / (without spaces). My design validates perfectly to HTML5. Now what I’m trying to get is make the design accessible to WCAG 2.0 AA. You can test this at https://achecker.ca/checker/, first of all, no matter what I do to the theme, I can’t get rid of the XML namespace as I thought that may resolve the issue. The problem is the following:

    Check 49: Document has invalid language code.
    Repair: Add a valid 2 letter or 3 letter language code as defined in the ISO 639 specification to the HTML ‘lang’ attribute. For XHTML, both ‘lang’ and ‘xml:lang’ must be set.
    Line 1, Column 1:
    <html lang=”en” xmlns=”https://www.w3.org/1999/xhtml”&gt;
    <head>
    <link rel=”stylesheet” type=”text/css” …

    If I’ve already got a valid language code ‘en’ (and I’ve tried everything) using the ‘lang’ attribute, then why is it not validating the website I don’t understand what’s wrong. I had a feeling the XML namespace has something to do with it though I have no way to get rid of it, it seems to be built in.

    I should be able to fix this being a web designer but this is the first time I’ve ever come across anything like this. I look forward to hearing what other people have to say about this and if anyone knows how to sort it out then that would be amazing.

    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Validators are only tools and the HTML5 validator is still experimental.

    Thread Starter html5rules

    (@html5rules)

    Thanks for your reply, I am aware of this. I removed the XML namespace from within my code that was giving me the WCAG error. However, I noticed that using the above WAI validator, the XML namespace appeared in the code, and when I validate the HTML using W3Cs service, the XML namespace isn’t there like it should be. I then took that code and pasted it in the WAI validator which came out valid.

    I think what WordPress does is add the XML namespace to certain user agents, I don’t know which ones but that seems to be the root of the problem and perhaps something the official team should have a look at when make the transition to HTML5 in the future as the namespace is only used in XHTML so it shouldn’t be there in the first place.

    Well that’s managed to sort out the problem in a kind of way but definitely something that should be looked in to.

    You could try posting this as a bug on Trac

    Thread Starter html5rules

    (@html5rules)

    Thanks, I’ve reported this as a bug and tagged that it needs more documentation. On the support files it actually says we don’t need to know about XML namespace which I think is a bit biased if you’re a developer… Nevertheless, we’ll see what they have to say.

    Can you post the code from your header.php file that’s generating the first part of the markup?

    Thread Starter html5rules

    (@html5rules)

    <!DOCTYPE html>
    <html lang=”en”>
    <head>

    You can see that I don’t really want the XML namespace there because it’s HTML5 and like I said, when you look at the source from https://achecker.ca/checker/ you can see how it’s changed my code and on the W3C validator the source is just as it should be.

    … if that’s the code, then I don’t see how WordPress could possibly be adding the xmlns declaration. If you had instead:

    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>

    Then I could see something happening. But WordPress itself does not do anything to the <html> tag on its own. What plugins are you running? One of them might be forcing the change … or there could be something on your site that’s causing the validator to add it.

    Actually, scratch that.

    Turn off your cache!

    When I load your page directly in the browser and I view the source, I don’t see any problems with the <html> declaration. When I turn on the “show source” option for your validator, I can see the xmlns tag and this code in the footer:

    <!-- W3 Total Cache: Minify debug info:
    Engine: disk
    Theme: 1c66c
    Template: home
    Replaced CSS files:
    1. wp-content/themes/sohailtech/style.css
    -->
    <!-- Performance optimized by W3 Total Cache. Learn more: https://www.w3-edge.com/wordpress-plugins/
    Database Caching using disk
    Object Caching 1132/1248 objects using disk
    Content Delivery Network via cdn.sohailtech.com
    Served from: www.sohailtech.com @ 2011-06-17 13:51:20 -->

    When the validator tries to access your site, it’s pulling a static, cached version of the homepage!

    Thread Starter html5rules

    (@html5rules)

    Eric, it’s not the cache, I’ve tried that many times. If I were to remove the ‘lang’ attribute from the header and try the https://achecker.ca/checker/ validator again after flushing the cache you can see the change because then the ‘lang’ attribute isn’t there but the XML namespace still is.

    <html xmlns=”https://www.w3.org/1999/xhtml”&gt;

    And I just tried that now so the cache is not the source of the problem, I even tried disabling the W3 plugin and turning it back on after.

    I did some more digging, and I’m answering here because this definitely does not belong on Trac.

    The problem is 50% caused by W3 Total Cache and 50% caused by the validator you’re using.

    After I poked at the code for W3TC I discovered that it does indeed include code for forcing XHTML. Apparently there’s an option you have to explicitly set to switch to HTML, otherwise it assumes you’re working with XHTML and replaces the <!DOCTYPE> declaration before serving the page. I couldn’t dig too far into the code, but my best guess is that it either also forces the xmlns tag as well as a result.

    The other problem is the validator. It seems to be caching the response from the server. I know you’ve done some work to disable W3TC on your end, and every other validator I can find serves up the appropriate HTML version on the site (without the annoying xmlns tag). But the validator you’re using keeps serving up a cached version.

    So either the validator is talking to your CDN and pulling down a cached version of the site, or it has its own cached version that’s not working right.

    I did verify in 2 other web accessibility scanners, and they don’t see the xmlns tag at all.

    Thread Starter html5rules

    (@html5rules)

    Yes actually it was completely because of the W3 Total Cache plugin meaning there’s a bug or something there, more specifically it was the Minify feature causing this so I’m looking into it now.

    Thanks for everyone’s help!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘HTML5 Lang Attribute problems’ is closed to new replies.