Validation warnings on W3C mobileOK Checker

Hi,

I am developing a mobile website and trying to validate it on W3C mobileOK Checker: http://validator.w3.org/mobile/.

I got a score of 100% and it says “The page is mobileOK!”; though, there are some warnings in the “Detailed Report section”. I cannot link to the actual page since this is a special project but here is the code I use in the beginning of the HTML codument:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Title</title>
	<meta http-equiv="Content-type" content="application/xhtml+xml;charset=UTF-8" />
	<meta http-equiv="Cache-control" content="max-age=300" />
	<meta name="viewport" content="width=device-width; initial-scale=1" />
	<meta name="handheldfriendly" content="true"/>
	<meta name="description" content="" />
	<meta name="keywords" content="" />
	<link rel="stylesheet" type="text/css" href="style.css" charset="UTF-8" />
</head>

and I have the following at the beginning of my style.css file.

@charset "UTF-8";

Below is a list of warnings that I couldn’t get rid of.

  • The document’s caching information is not provided in the HTTP headers
  • A matching HTTP response header does not exist for the meta http-equiv element
  • An HTTP response header that matches the meta http-equiv element exists but their values differ
  • The resource does not specify UTF-8 as character encoding
  • The linked resource character encoding may not be appropriate for mobile devices
  • The document is not served as “application/xhtml+xml”

Do you any have idea about how to get rid of these warnings?

To me it mainly sounds like your server isn’t optimised and since ‘XHTML Basic’ is supposed to be served as “application/xhtml+xml”. Like I have on this ancient beta http://www.xhtmlcoder.com/beck/ (for browsers that accept and the markup validator) but I didn’t design it for mobile conformance.

Your META is basically redundant for encoding for browsers supporting the recommended XHTML “application/xhtml+xml” MIME I suspect that is what some of the warning problems are. It should be done at server level the: <meta http-equiv=“Content-type” content=“application/xhtml+xml;charset=UTF-8” /> is meaningless to an XML Processor, and won’t make your page magically served as XHTML.

It will still remain ‘text/html’ and be parsed by legacy browsers and won’t halt on FATAL errors such as failing well-formedness.

This might help: http://www.w3.org/International/questions/qa-html-encoding-declarations basically you might want to use something like PHP to do content negotiation or set the HTTP headers, etc.

Note: a live site would be needed to see those errors you have listed via the mobileOK anyway since they concern both HTTP and your CSS, etc.

Hi Robert,

Thanks for your reply. I am testing this on a shared hosting. What do you mean by “your server isn’t optimised”? How do I set set the HTTP headers? By the way, I am not sure if I need the XML declaration or not (<?xml version=“1.0” encoding=“UTF-8”?>), but when I add it, it eliminates one error.

I think adding

# Enable the mod_expires module
ExpiresActive On
# Set expiration date to 1 month for all style sheets and images
ExpiresByType text/css "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
# Set expiration date to 1 week for all HTML pages
ExpiresByType text/html "access plus 1 week"
ExpiresByType application/xhtml+xml "access plus 1 week"

AddDefaultCharset UTF-8

AddCharset UTF-8 .css

to your .htaccess file will solve your caching information warning and your character encoding problems (assuming you are using UTF-8, of course :slight_smile: ).

You might also find RedBot useful for seeing what’s happening.

I was checking that .htaccess solutions but since not all the websites are hosted on Apache, I need to find another solution. This will be a template and I have no control over on which servers people will use it.