Hello. It appears that the theme generates code which does not pass the W3C validator (69 errors). The problems seem to be mostly with the DOCTYPE and the xmlns namespace declarations. I needed to modify html.tpl.php in my sub-theme in order to pass the W3C validator, to generate code as follows.

  1. Changed the DOCTYPE declaration. It seemed to point to the older XHTML DTD even though the theme is an HTML5 theme
  2. Removed xmlns attributes from the html tag. In reading about xmlns namespaces, it does not appear that these are needed when using HTML 5
  3. Simplify head declaration
  4. Modified the meta declaration. "chrome=1" seems to make validation fail, and it isn't in the HTML5 boilerplate

Please comment-- are these changes OK or will they break something else in the theme? I'm new to Drupal and I know we are using 7.37 but I'm not sure what the "-3.x-dev" or "-4.x-dev" part of the version means, or which one of those we are using.

Thanks.

Old Generated Code (before fixing errors):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html lang="en" dir="ltr"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:dc="http://purl.org/dc/terms/"
  xmlns:foaf="http://xmlns.com/foaf/0.1/"
  xmlns:og="http://ogp.me/ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:sioc="http://rdfs.org/sioc/ns#"
  xmlns:sioct="http://rdfs.org/sioc/types#"
  xmlns:skos="http://www.w3.org/2004/02/skos/core#"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
<head profile="http://www.w3.org/1999/xhtml/vocab">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">

New Generated Code (no more errors):

<!doctype html>
<html lang="en" dir="ltr">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">

Comments

markhalliwell’s picture

Issue tags: -W3C validation
Related issues: +#2184165: Use HTML5 doctype

The doctype has actually already been fixed by this related issue.

As far as the XML namespaces, they are are actually ignored by browsers per the spec http://www.w3.org/TR/html5/dom.html#global-attributes:

In HTML, the xmlns attribute has absolutely no effect. It is basically a talisman. It is allowed merely to make migration to and from XHTML mildly easier. When parsed by an HTML parser, the attribute ends up in no namespace, not the "http://www.w3.org/2000/xmlns/" namespace like namespace declaration attributes in XML do.

It's widely known that W3C isn't always accurate in its reporting (as evidence by these errors as they really should be ignored or at least deprecated to info/warnings). They even say it on their page:

Using experimental feature: HTML5 Conformance Checker.

The validator checked your document with an experimental feature: HTML5 Conformance Checker. This feature has been
made available for your convenience, but be aware that it may be unreliable, or not perfectly up to date with the latest development of some cutting-edge technologies. If you find any issues with this feature, please report them. Thank you.

That being said, I don't see how removing these would affect anything negatively and should be safe to do so. These (just like the doctype) was really just an oversight from migrating the old BS2 code to BS3.

P.S., 7.x-3.x is correct as this is the current HEAD. 7.x-4.x is just for whenever Bootstrap decides to actually publish some BS4 code and then we can start development in that branch for upgrading. It's also used in this IQ to help postpone issues for a later release (categorizing).

markhalliwell’s picture

Title: W3C validator errors on generated theme code » Remove deprecated attributes from html.tpl.php
Related issues: +#2286857: Improve IE support documentation

<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
This project does not add this meta tag (see related issue for an in-depth explanation as to why), so it must be coming from some other project... perhaps https://www.drupal.org/project/html5_tools?

Re: removing the attributes
After reading http://www.phase2technology.com/blog/w3c-validation-for-drupal-7-html5-r..., I don't think the solution is to actually remove them, instead I think they should instead be converted. They're still needed for RDF.

markhalliwell’s picture

Title: Remove deprecated attributes from html.tpl.php » Convert deprecated attributes in html.tpl.php

Err... wrong title heh

northk’s picture

Mark,

Thank you very much for your detailed review!

  • markcarver committed ecef20e on
    Issue #2501275: Convert deprecated attributes in html.tpl.php
    
markhalliwell’s picture

Version: 7.x-3.x-dev » 8.x-3.x-dev
Assigned: Unassigned » neardark
Status: Active » Patch (to be ported)

@neardark, please double check that this is similar in 8.x.

dakku’s picture

confirmed to be correct in D8 branch. I guess this can be closed...

Here is a copy paste from:
http://cgit.drupalcode.org/bootstrap/tree/templates/system/html.html.twi...

<!DOCTYPE html>
<html lang="{{ language.language }}" dir="{{ language.dir }}"{{ rdf_namespaces }}>
<head profile="{{ grddl_profile }}">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  {{ head }}
  <title>{{ head_title|safe_join(' | ') }}</title>
  {{ styles }}
  <!-- HTML5 element support for IE6-8 -->
  <!--[if lt IE 9]>
    <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
  {{ scripts }}
</head>
dakku’s picture

Status: Patch (to be ported) » Reviewed & tested by the community
markhalliwell’s picture

Status: Reviewed & tested by the community » Closed (fixed)