There is really no point in using the XHTML doctype, since the Bartik theme uses the text/html MIME type. The current code is actually HTML5, but with the wrong doctype. Solution: change the doctype from XHTML to HTML5:

<!DOCTYPE html>

You can only use XHTML features in the application/xhtml+xml MIME type, but that is not supported in IE 6-7-8. So why use the XHTML doctype? Because maybe in the future you can change to the application/xhtml+xml MIME type? Forget that, since IE 6-7-8 have 50% market share. By the time you can use the application/xhtml+xml MIME type, it will be obsolete.

Comments

damien tournoud’s picture

Status: Active » Closed (duplicate)

Drupal 7 uses XHTML+RDFa 1.0. This looks perfectly correct.

For discussions about HTML5 (and more precisely XHTML5), see #963832: Decide how to use HTML5 in Drupal 8.

Bence’s picture

Status: Closed (duplicate) » Active

Yes, the syntax is perfectly correct, but the MIME type is wrong!

The MIME type is the boss: user agents don't care if you have the perfect XHTML doctype and syntax, if you send them in text/html, then your code IS HTML, and NOT XHTML.

The internet media type of XHTML+RDFa is application/xhtml+xml. But Bartik uses the text/html, this is simply wrong.

Similarly, you don't send your JPG images in image/png, or your webM videos in video/mp4, or your plain text files in text/xml.

But I know that IE 7-8 doesn't support application/xhtml+xml, so XHTML is not an option, only HTML5.

What's the problem with this code? Isn't RDFa 1.1 backwards compatible with RDF 1.0?

<!DOCTYPE html>
<html version="HTML+RDFa 1.1" lang="en" dir="ltr">
robloach’s picture

This is hard coded into html.tpl.php.... Subscribe.

scor’s picture

Status: Active » Closed (duplicate)

I remember looking at the MIME issue many months ago while working on RDFa in Drupal 7. Switching from text/html to application/xhtml+xml was (and still is) a no go since it would blow up in old browsers as you know it. RDFa 1.0 is still the only official RDFa spec today and it requires the doctype XHTML+RDFa 1.0, but to ensure compatility with older browser it is served as text/html. This does not prevent agents to parse your page as XHTML if they like. Serving XHTML document as text/html is still what you will encounter a lot today on the Web (look at http://en.wikipedia.org/wiki/Drupal for example). RDFa 1.1 will allow to serve RDFa with a non-XHTML doctype this but it's still a draft. Given that Drupal 7 is in RC2, I'm closing this issue in favor of the ongoing discussion for Drupal 8 at #963832: Decide how to use HTML5 in Drupal 8.

RDFa in XHTML: Syntax and Processing (RDFa 1.0) says

XHTML+RDFa documents SHOULD be labeled with the Internet Media Type "application/xhtml+xml" as defined in [RFC3236].

SHOULD is not a strict requirement, if you have good reasons not follow this, it does not make your document invalid in any way.

Jeff Burnz’s picture

Component: Bartik theme » markup
Status: Closed (duplicate) » Active

text/html utilizes XHTML's backward compatibility mode.

I'm not sure I see the value in changing this for D7, I think we need some really clear guidelines on RDFa before doing so. Certainly for D8 the current motivation is to switch to HTML5 but I am not seeing any reason (so far, please chime in) to hurry that along.

This debate is bigger than Bartik.

Jeff Burnz’s picture

Status: Active » Closed (duplicate)

Cross post.

Bence’s picture

Ok, I agree on closing this. HTML5 features (like audio and video tag) work anyway, regardless of the doctype.

jensimmons’s picture

I wanted to make Bartiks' doctype HTML5. It was for a while (long before anyone but me saw the code). I knew, however, that if Bartik had any chance of being accepted as a core theme, I had to use whatever doctype Drupal core was using. So I copied the doctype from html.tpl.php in core.

In fact, these days Bartik doesn't even have a doctype!! Look at the theme code. There's no doctype anywhere to be found. The html.tpl.php file was removed — so now Bartik pulls the doctype from the htmltpl.php file in the system module.

Also, it's awfully late for this. Drupal 7 is almost done.

You can only use XHTML features in the application/xhtml+xml MIME type, but that is not supported in IE 6-7-8. So why use the XHTML doctype?

AND well, you are just wrong. XHTML 1.0 served as text is a well-known, professional way to do things. There is no way we want to serve Drupal html as xml. Absolutely not. No. No.

If we do that, and someone builds a Drupal site for a client, and that client writes their own HTML but doesn't write it perfectly... then the website will fail. Who wants that? Google this debate and read. All the top HTML/CSS/doctype experts agree. And everyone uses XHTML 1.0 instead of XHTML 1.1 for this reason. Look, from http://happycog.com (The Webstandard's expert's company)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Happy Cog</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

XHTML 1.0 served as text/html.

The same will be true for Drupal 8 HTML5. NOT served as xml.