h5bp / html5-boilerplate

A professional front-end template for building fast, robust, and adaptable web apps or sites.
https://html5boilerplate.com/
MIT License
56.39k stars 12.22k forks source link

html5 and RDFa doctype and namespaces #178

Closed tombigel closed 13 years ago

tombigel commented 13 years ago

It's less of a boilerplate question and more of an HTML5 standards and conventions question:

I'm working on a website based on Drupal 7 beta. Drupal 7 default themes are packed with RDFa (http://www.w3.org/TR/rdfa-in-html/) tags and XML namespaces set on the HTML tag and throughout the document, and also using a DOCTYPE I've never seen before. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

I'm trying to keep both Drupal's conventions while maintaining HTML5 conventions and html5boilerplate goodness.

One good example is using IE conditional comments and those RDFa conventions: This is the Drupal theme code i wrote for the HTML tag:

     <!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
    <!--[if lt IE 7 ]> <html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>" version="XHTML+RDFa 1.0" <?php print $rdf_namespaces?> class="no-js ie ie6 lte7 lte8 lte9"> <![endif]-->
    <!--[if IE 7 ]>    <html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>" version="XHTML+RDFa 1.0" <?php print $rdf_namespaces?> class="no-js ie ie7 lte7 lte8 lte9"> <![endif]-->
    <!--[if IE 8 ]>    <html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>" version="XHTML+RDFa 1.0" <?php print $rdf_namespaces?> class="no-js ie ie8 lte8 lte9"> <![endif]-->
    <!--[if IE 9 ]>    <html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>" version="XHTML+RDFa 1.0" <?php print $rdf_namespaces?> class="no-js ie ie9 lte9"> <![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!--> <html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>" version="XHTML+RDFa 1.0" <?php print $rdf_namespaces?> class="no-js"> <!--<![endif]-->

And this is what Drupal generates:

    <!--[if lt IE 7 ]> <html lang="he" dir="rtl" version="XHTML+RDFa 1.0" 
      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#" class="no-js ie ie6 lte7 lte8 lte9"> <![endif]-->
    <!--[if IE 7 ]>    <html lang="he" dir="rtl" version="XHTML+RDFa 1.0" 
      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#" class="no-js ie ie7 lte7 lte8 lte9"> <![endif]-->
    <!--[if IE 8 ]>    <html lang="he" dir="rtl" version="XHTML+RDFa 1.0" 
      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#" class="no-js ie ie8 lte8 lte9"> <![endif]-->
    <!--[if IE 9 ]>    <html lang="he" dir="rtl" version="XHTML+RDFa 1.0" 
      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#" class="no-js ie ie9 lte9"> <![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!--> <html lang="he" dir="rtl" version="XHTML+RDFa 1.0" 
      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#" class="no-js"> <!--<![endif]-->

It's not a disaster, but it feels so much redundant...

I found some references over the internet about using RDFa and HTML5 but couldn't find clear answers about what is mandatory, what is standard and what can be ommited for clearer code.

Any thoughts?

adeelejaz commented 13 years ago

I remember seeing a similar issue already reported. I think we should be put a wiki up explaining how to switch conditional comments from to with pros and cons for both.

tombigel commented 13 years ago

With Drupal the body also creates a lot of redundant code because it is assigned many classes through Drupal's theming system.

tombigel commented 13 years ago

I hate the "Comment and Close" button. Pressed it by mistake again..

adeelejaz commented 13 years ago

How about this: http://trashb.info/87826f7b

PS: Sorry for posting the code in the link, github keeps eating my code :(

tombigel commented 13 years ago

You have to replace all > and < with &gt and &lt (with a semicolon after them)

About your solution, it is elegant, but the beauty of the original is that it doesn't use scripts at all.