diff -aur original/odoc_html.ml patched/odoc_html.ml
--- original/odoc_html.ml	2014-09-14 09:18:23.000000000 +0200
+++ patched/odoc_html.ml	2014-09-14 09:18:23.000000000 +0200
@@ -22,6 +22,7 @@
 open Class
 open Module
 
+let html5 = ref false
 let with_parameter_list = ref false
 let css_style = ref None
 let index_only = ref false
@@ -29,6 +30,61 @@
 let html_short_functors = ref false
 let charset = ref "iso-8859-1"
 
+(* HTML 5 / Bootstrap specific elements *)
+let if_html5 x y = if !html5 then x else y
+let doc_type () = if_html5 "<!DOCTYPE html>\n" "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
+let open_bold       () = if_html5 "<strong>"     "<b>"
+let close_bold      () = if_html5 "</strong>"    "</b>"
+let open_italic     () = if_html5 "<em>"         "<i>"
+let close_italic    () = if_html5 "</em>"        "</i>"
+let open_fixed      () = if_html5 "<tt>"         "<pre>"
+let close_fixed     () = if_html5 "</tt>"        "</pre>"
+let open_sup        () = if_html5 "<sup>"        "<sup class=\"superscript\">"
+let close_sup       () = if_html5 "</sup>"       "</sup>"
+let open_sub        () = if_html5 "<sub>"        "<sub class=\"subscript\">"
+let close_sub       () = if_html5 "</sub>"       "</sub>"
+let open_type       () = if_html5 "<tt class=\"type\">" "<code class=\"type\">"
+let close_type      () = if_html5 "</tt>"        "</code>"
+let open_kbd        () = if_html5 "<kbd>"        "<tt>"
+let close_kbd       () = if_html5 "</kbd>"       "</tt>"
+let open_strike     () = if_html5 "<s>"          "<strike>"
+let close_strike    () = if_html5 "</s>"         "</strike>"
+let open_underline  () = if_html5 "<u>"          "<u>"
+let close_underline () = if_html5 "</u>"         "</u>"
+let open_table      () = if_html5 "<table class=\"table table-striped table-hover table-condensed\">"        "<table>"
+let close_table     () = if_html5 "</table>"     "</table>"
+let new_line        () = if_html5 "\n<br><br>\n" "\n<p>\n"
+let open_container  () = if_html5 "<div class=\"container\" style=\"max-width: 48em;\">"   ""
+let close_container () = if_html5 "</div>"       ""
+let open_row        () = if_html5 "<div class=\"row\">\n" ""
+let close_row       () = if_html5 "</div>\n"     ""
+let empty_row       () = if_html5 "<div class=\"row\">&nbsp;</div>\n" ""
+let bootstrap_files = [
+  "bootstrap.min.css" ;
+  "glyphicons-halflings-regular.eot" ;
+  "glyphicons-halflings-regular.svg" ;
+  "glyphicons-halflings-regular.ttf" ;
+  "glyphicons-halflings-regular.woff"
+]
+let bootstrap_css = "bootstrap.min.css"
+
+let base_url_of_class java_name =
+  try
+    !Odoc_global.java_url_bases
+    |> List.find
+        (fun (prefix, url_base) ->
+          let len_prefix = String.length prefix in
+          if len_prefix < String.length java_name then begin
+            let i = ref 0 in
+            while (!i < len_prefix) && (prefix.[!i] = java_name.[!i]) do
+              incr i
+            done;
+            !i = len_prefix
+          end else
+            false)
+    |> snd
+  with _ ->
+    !Odoc_global.jdk_base_url
 
 (** The functions used for naming files and html marks.*)
 module Naming =
@@ -221,6 +277,53 @@
 let bs = Buffer.add_string
 
 
+module Tables : sig
+  type state
+  val make_state : unit -> state
+  val begin_table : state -> unit
+  val end_table : state -> unit
+  val begin_row : state -> unit
+  val end_row : state -> unit
+  val add_cell : state -> unit
+  val add_cells : int -> state -> unit
+end = struct
+  type state = {
+      row_stack : (int option * int) Stack.t;
+      mutable last_row_length : int option;
+      mutable current_row_length : int;
+    }
+  let make_state () =
+    { row_stack = Stack.create ();
+      last_row_length = None;
+      current_row_length = 0; }
+  let begin_table st =
+    Stack.push (st.last_row_length, st.current_row_length) st.row_stack;
+    st.last_row_length <- None;
+    st.current_row_length <- 0
+  let end_table st =
+    let last, curr = Stack.pop st.row_stack in
+    st.last_row_length <- last;
+    st.current_row_length <- curr
+  let begin_row _ =
+    ()
+  let end_row st =
+    (match st.last_row_length with
+    | Some x ->
+        if x <> st.current_row_length then
+          let msg =
+            Printf.sprintf "table row has invalid length (%d instead of %d)"
+              st.current_row_length
+              x in
+          Odoc_info.warning msg
+    | None ->
+        st.last_row_length <- Some st.current_row_length);
+    st.current_row_length <- 0
+  let add_cell st =
+    st.current_row_length <- succ st.current_row_length
+  let add_cells n st =
+    st.current_row_length <- st.current_row_length + n
+end
+
 (** Generation of html code from text structures. *)
 class virtual text =
   object (self)
@@ -290,7 +393,118 @@
       | Odoc_info.Custom (s,t) -> self#html_of_custom_text b s t
       | Odoc_info.Target (target, code) -> self#html_of_Target b ~target ~code
 
-    method html_of_custom_text b s t = ()
+    val tables = Tables.make_state ()
+
+    method html_of_custom_text buff tag text =
+      let string_of_text text =
+        let tmp = Buffer.create 256 in
+        self#html_of_text tmp text;
+        Buffer.contents tmp in
+      let trimmed_string_of_text text =
+        text
+        |> string_of_text
+        |> String.trim in
+      let add s =
+        Buffer.add_string buff s in
+      match tag with
+      | "k" ->
+          add (open_kbd ());
+          self#html_of_text buff text;
+          add (close_kbd ())
+      | "s" ->
+          add (open_strike ());
+          self#html_of_text buff text;
+          add (close_strike ())
+      | "u" ->
+          add (open_underline ());
+          self#html_of_text buff text;
+          add (close_underline ())
+      | "table" ->
+          Tables.begin_table tables;
+          add (open_table ());
+          self#html_of_text buff text;
+          add (close_table ());
+          Tables.end_table tables
+      | "caption" ->
+          add "<caption>";
+          self#html_of_text buff text;
+          add "</caption>"
+      | "header" ->
+          Tables.add_cell tables;
+          add "<th>";
+          self#html_of_text buff text;
+          add "</th>"
+      | "row" ->
+          Tables.begin_row tables;
+          add "<tr>";
+          self#html_of_text buff text;
+          add "</tr>";
+          Tables.end_row tables
+      | "data" ->
+          Tables.add_cell tables;
+          add "<td>";
+          self#html_of_text buff text;
+          add "</td>"
+      | "span" ->
+          let text = trimmed_string_of_text text in
+          let idx1 = try String.index text ' ' with Not_found -> max_int in
+          let idx2 = try String.index text '\t' with Not_found -> max_int in
+          let idx = min idx1 idx2 in
+          if idx < max_int then
+            let sz = String.sub text 0 idx in
+            try
+              let n = int_of_string sz in
+              if n >= 1 then begin
+                Tables.add_cells n tables;
+                let text = String.sub text idx ((String.length text) - idx) in
+                add ("<td colspan=\"" ^ sz ^ "\">");
+                add text;
+                add "</td>"
+              end else
+                Odoc_info.warning "span size should be positive"
+            with Failure _ ->
+              Odoc_info.warning "span size should be an integer"
+          else
+            Odoc_info.warning "span size is missing"
+      | "java" ->
+          let text = trimmed_string_of_text text in
+          let len = String.length text in
+          let tmp_buff = Buffer.create len in
+          let idx_parent = ref None in
+          for i = 0 to pred len do
+            match text.[i] with
+            | '.' -> Buffer.add_char tmp_buff (if !idx_parent = None then '/' else '.')
+            | '$' -> Buffer.add_char tmp_buff '.'
+            | '(' -> Buffer.add_char tmp_buff '('; idx_parent := Some i
+            | ch  -> Buffer.add_char tmp_buff ch
+          done;
+          let target = Buffer.contents tmp_buff in
+          let class_name, anchor =
+            try
+              let idx = String.index target '#' in
+              String.sub target 0 idx,
+              String.sub target idx (String.length target - idx)
+            with _ ->
+              target, "" in
+          add "<tt><a href=\"";
+          add (base_url_of_class class_name);
+          add class_name;
+          add ".html";
+          add anchor;
+          add "\">";
+          begin match !idx_parent with
+          | None -> add text
+          | Some idx ->
+              try
+                let idx_sharp = String.rindex text '#' in
+                let meth = String.sub text (succ idx_sharp) (idx - idx_sharp - 1) in
+                add meth;
+                add "(...)"
+              with _ ->
+                add text
+          end;
+          add "</a></tt>";
+      | _ -> ()
 
     method html_of_Target b ~target ~code =
       if String.lowercase target = "html" then bs b code else ()
@@ -335,11 +549,62 @@
                 None -> String.sub s first 1
               | Some last -> String.sub s first ((last-first)+1)
         in
+        let leading_spaces s =
+          let i = ref 0 in
+          let len = String.length s in
+          while (!i < len) && (s.[!i] = ' ') do
+            incr i;
+          done;
+          !i in
+        let spaces_only s =
+          (leading_spaces s) = (String.length s) in
+        let cut_lines s =
+          let buff = Buffer.create 128 in
+          let res = ref [] in
+          for i = 0 to pred (String.length s) do
+            match s.[i] with
+            | '\n' ->
+                let line = Buffer.contents buff in
+                if spaces_only line then
+                  res := "" :: !res
+                else
+                  res := line :: !res;
+                Buffer.reset buff
+            | '\t' ->
+                Buffer.add_string buff "    "
+            | ch ->
+                Buffer.add_char buff ch
+          done;
+          List.rev !res in
+        let minimize_indent s =
+          let lines = cut_lines s in
+          let min_indent =
+            List.fold_left
+              (fun acc line ->
+                match line, acc with
+                | "", (None | Some _) -> acc
+                | _, None             -> Some (leading_spaces line)
+                | _, Some curr_min    -> Some (min curr_min (leading_spaces line)))
+              None
+              lines in
+          match min_indent with
+          | Some k when k > 2 ->
+              let k = k - 2 in
+              let buff = Buffer.create 1024 in
+              List.iter
+                (fun line ->
+                  if line <> "" then
+                    let line = String.sub line k (String.length line - k) in
+                    Buffer.add_string buff line;
+                  Buffer.add_char buff '\n')
+                lines;
+              Buffer.contents buff
+          | Some _ | None -> s in
         fun b s ->
       if !colorize_code then
           (
            bs b "<pre class=\"codepre\">";
-           self#html_of_code b (remove_useless_newlines s);
+           self#html_of_code b (minimize_indent (remove_useless_newlines s));
            bs b "</pre>"
           )
       else
@@ -347,7 +612,7 @@
          bs b "<pre class=\"codepre\"><code class=\"";
          bs b Odoc_ocamlhtml.code_class;
          bs b "\">" ;
-         bs b (self#escape (remove_useless_newlines s));
+         bs b (self#escape (minimize_indent (remove_useless_newlines s)));
          bs b "</code></pre>"
         )
 
@@ -357,14 +622,14 @@
       bs b "</pre>"
 
     method html_of_Bold b t =
-      bs b "<b>";
+      bs b (open_bold ());
       self#html_of_text b t;
-      bs b "</b>"
+      bs b (close_bold ())
 
     method html_of_Italic b t =
-      bs b "<i>" ;
+      bs b (open_italic ()) ;
       self#html_of_text b t;
-      bs b "</i>"
+      bs b (close_italic ())
 
     method html_of_Emphasize b t =
       bs b "<em>" ;
@@ -400,7 +665,7 @@
         tl;
       bs b "</OL>\n"
 
-    method html_of_Newline b = bs b "\n<p>\n"
+    method html_of_Newline b = bs b (new_line ())
 
     method html_of_Block b t =
       bs b "<blockquote>\n";
@@ -472,19 +737,20 @@
           bs b "</a>"
 
     method html_of_Superscript b t =
-      bs b "<sup class=\"superscript\">";
-      self#html_of_text b t;
-      bs b "</sup>"
+        bs b (open_sup ());
+        self#html_of_text b t;
+        bs b (close_sup ())
 
     method html_of_Subscript b t =
-      bs b "<sub class=\"subscript\">";
+      bs b (open_sub ());
       self#html_of_text b t;
-      bs b "</sub>"
+      bs b (close_sub ())
 
     method virtual html_of_info_first_sentence : _
 
     method html_of_Module_list b l =
-      bs b "<br>\n<table class=\"indextable\">\n";
+      bs b (if_html5 "<br>\n<table class=\"table table-striped table-condensed table-hover\">\n"
+                     "<br>\n<table class=\"indextable\">\n");
       List.iter
         (fun name ->
           bs b "<tr><td class=\"module\">";
@@ -562,7 +828,7 @@
       match l with
         [] -> ()
       | _ ->
-          bp b "<b>%s:</b> " Odoc_messages.authors;
+          bp b "%s%s:%s " (open_bold ()) Odoc_messages.authors (close_bold ());
           self#html_of_text b [Raw (String.concat ", " l)];
           bs b "<br>\n"
 
@@ -571,7 +837,7 @@
       match v_opt with
         None -> ()
       | Some v ->
-           bp b "<b>%s:</b> " Odoc_messages.version;
+           bp b "%s%s:%s " (open_bold ()) Odoc_messages.version (close_bold ());
            self#html_of_text b [Raw v];
            bs b "<br>\n"
 
@@ -580,16 +846,16 @@
       match s_opt with
         None -> ()
       | Some s ->
-          bp b "<b>%s</b> " Odoc_messages.since;
+          bp b "%s%s%s " (open_bold ()) Odoc_messages.since (close_bold ());
           self#html_of_text b [Raw s];
           bs b "<br>\n"
 
     (** Print html code for the given "before" information.*)
     method html_of_before b l =
       let f (v, text) =
-        bp b "<b>%s " Odoc_messages.before;
+        bp b "%s%s " (open_bold ()) Odoc_messages.before;
         self#html_of_text b [Raw v];
-        bs b " </b> ";
+        bp b " %s "(close_bold ());
         self#html_of_text b text;
         bs b "<br>\n"
       in
@@ -600,13 +866,15 @@
       match l with
         [] -> ()
       | (s, t) :: [] ->
-          bp b "<b>%s</b> <code>%s</code> "
+          bp b "%s%s%s <code>%s</code> "
+            (open_bold ())
             Odoc_messages.raises
+            (close_bold ())
             s;
           self#html_of_text b t;
           bs b "<br>\n"
       | _ ->
-          bp b "<b>%s</b><ul>" Odoc_messages.raises;
+          bp b "%s%s%s<ul>" (open_bold ()) Odoc_messages.raises (close_bold ());
           List.iter
             (fun (ex, desc) ->
               bp b "<li><code>%s</code> " ex ;
@@ -631,11 +899,11 @@
       match l with
         [] -> ()
       | see :: [] ->
-          bp b "<b>%s</b> " Odoc_messages.see_also;
+          bp b "%s%s%s " (open_bold ()) Odoc_messages.see_also (close_bold ());
           self#html_of_see b see;
           bs b "<br>\n"
       | _ ->
-          bp b "<b>%s</b><ul>" Odoc_messages.see_also;
+          bp b "%s%s%s<ul>" (open_bold ()) Odoc_messages.see_also (close_bold ());
           List.iter
             (fun see ->
               bs b "<li>" ;
@@ -650,7 +918,7 @@
       match return_opt with
         None -> ()
       | Some s ->
-          bp b "<b>%s</b> " Odoc_messages.returns;
+          bp b "%s%s%s " (open_bold ()) Odoc_messages.returns (close_bold ());
           self#html_of_text b s;
           bs b "<br>\n"
 
@@ -763,7 +1031,7 @@
     inherit info
 
     val mutable doctype =
-      "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
+      doc_type ()
     method character_encoding () =
       Printf.sprintf
         "<meta content=\"text/html; charset=%s\" http-equiv=\"Content-Type\">\n"
@@ -771,86 +1039,157 @@
 
     (** The default style options. *)
     val mutable default_style_options =
-      [ ".keyword { font-weight : bold ; color : Red }" ;
-        ".keywordsign { color : #C04600 }" ;
-        ".superscript { font-size : 4 }" ;
-        ".subscript { font-size : 4 }" ;
-        ".comment { color : Green }" ;
-        ".constructor { color : Blue }" ;
-        ".type { color : #5C6585 }" ;
-        ".string { color : Maroon }" ;
-        ".warning { color : Red ; font-weight : bold }" ;
-        ".info { margin-left : 3em; margin-right: 3em }" ;
-        ".param_info { margin-top: 4px; margin-left : 3em; margin-right : 3em }" ;
-        ".code { color : #465F91 ; }" ;
-        ".typetable { border-style : hidden }" ;
-        ".paramstable { border-style : hidden ; padding: 5pt 5pt}" ;
-        "tr { background-color : White }" ;
-        "td.typefieldcomment { background-color : #FFFFFF ; font-size: smaller ;}" ;
-        "div.sig_block {margin-left: 2em}" ;
-        "*:target { background: yellow; }" ;
-
-        "body {font: 13px sans-serif; color: black; text-align: left; padding: 5px; margin: 0}";
-
-        "h1 { font-size : 20pt ; text-align: center; }" ;
-
-        "h2 { font-size : 20pt ; border: 1px solid #000000; "^
-        "margin-top: 5px; margin-bottom: 2px;"^
-        "text-align: center; background-color: #90BDFF ;"^
-        "padding: 2px; }" ;
-
-        "h3 { font-size : 20pt ; border: 1px solid #000000; "^
-        "margin-top: 5px; margin-bottom: 2px;"^
-        "text-align: center; background-color: #90DDFF ;"^
-        "padding: 2px; }" ;
-
-        "h4 { font-size : 20pt ; border: 1px solid #000000; "^
-        "margin-top: 5px; margin-bottom: 2px;"^
-        "text-align: center; background-color: #90EDFF ;"^
-        "padding: 2px; }" ;
-
-        "h5 { font-size : 20pt ; border: 1px solid #000000; "^
-        "margin-top: 5px; margin-bottom: 2px;"^
-        "text-align: center; background-color: #90FDFF ;"^
-        "padding: 2px; }" ;
-
-        "h6 { font-size : 20pt ; border: 1px solid #000000; "^
-        "margin-top: 5px; margin-bottom: 2px;"^
-        "text-align: center; background-color: #90BDFF ; "^
-        "padding: 2px; }" ;
-
-        "div.h7 { font-size : 20pt ; border: 1px solid #000000; "^
-        "margin-top: 5px; margin-bottom: 2px;"^
-        "text-align: center; background-color: #E0FFFF ; "^
-        "padding: 2px; }" ;
-
-        "div.h8 { font-size : 20pt ; border: 1px solid #000000; "^
-        "margin-top: 5px; margin-bottom: 2px;"^
-        "text-align: center; background-color: #F0FFFF ; "^
-        "padding: 2px; }" ;
-
-        "div.h9 { font-size : 20pt ; border: 1px solid #000000; "^
-        "margin-top: 5px; margin-bottom: 2px;"^
-        "text-align: center; background-color: #FFFFFF ; "^
-        "padding: 2px; }" ;
-
-        "a {color: #416DFF; text-decoration: none}";
-        "a:hover {background-color: #ddd; text-decoration: underline}";
-        "pre { margin-bottom: 4px; font-family: monospace; }" ;
-        "pre.verbatim, pre.codepre { }";
-
-        ".indextable {border: 1px #ddd solid; border-collapse: collapse}";
-        ".indextable td, .indextable th {border: 1px #ddd solid; min-width: 80px}";
-        ".indextable td.module {background-color: #eee ;  padding-left: 2px; padding-right: 2px}";
-        ".indextable td.module a {color: 4E6272; text-decoration: none; display: block; width: 100%}";
-        ".indextable td.module a:hover {text-decoration: underline; background-color: transparent}";
-        ".deprecated {color: #888; font-style: italic}" ;
-
-        ".indextable tr td div.info { margin-left: 2px; margin-right: 2px }" ;
-
-        "ul.indexlist { margin-left: 0; padding-left: 0;}";
-        "ul.indexlist li { list-style-type: none ; margin-left: 0; padding-left: 0; }";
-      ]
+      if !html5 then
+        [ ".keyword { font-weight: bold; color: #a94442; }" ; (* Bootstrap "danger" text color *)
+          ".keywordsign { color: #c04600; }" ;
+          (* superscript and subscript classes are replaced by bare <sup> and <sub> *)
+          ".comment { color: #3c763d; }" ; (* Bootstrap "success" text color *)
+          ".constructor { color: #31708f; }" ; (* Bootstrap "info" text color *)
+          ".type { color: #428bca; }" ; (* Bootstrap "primary" text color *)
+          ".string { color: #8a6d3b; }" ; (* Bootstrap "warning" text color *)
+          ".warning { color: #a94442; font-weight: bold; }" ;
+          ".info { margin-left: 3em; margin-right: 3em; }" ;
+          ".param_info { margin-top: 4px; margin-left: 3em; margin-right: 3em; }" ;
+          (* keep default color for "code" *)
+          ".typetable { border-style: hidden; }" ;
+          ".paramstable { border-style: hidden; padding: 5pt 5pt;}" ;
+          "tr { background-color: #ffffff; }" ;
+          "td.typefieldcomment { background-color: #ffffff; font-size: smaller; }" ;
+          "div.sig_block { margin-left: 2em; }" ;
+          "*:target { background: #ffff80; }" ;
+
+          "h1 { text-align: center; }" ;
+
+          "h2 { border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px; "^
+          "text-align: center; background-color: #a3daff; "^
+          "padding: 2px; }" ;
+
+          "h3 { border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px; "^
+          "text-align: center; background-color: #a3daff; "^
+          "padding: 2px; }" ;
+
+          "h4 { font-size: 24px; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px; "^
+          "text-align: center; background-color: #a3daff; "^
+          "padding: 2px; }" ;
+
+          "h5 { font-size: 24px; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px; "^
+          "text-align: center; background-color: #a3daff; "^
+          "padding: 2px; }" ;
+
+          "h6 { font-size: 24px; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px; "^
+          "text-align: center; background-color: #a3daff; "^
+          "padding: 2px; }" ;
+
+          "div.h7 { font-size: 24px; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px; "^
+          "text-align: center; background-color: #a3daff; "^
+          "padding: 2px; }" ;
+
+          "div.h8 { font-size: 24px; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px; "^
+          "text-align: center; background-color: #a3daff; "^
+          "padding: 2px; }" ;
+
+          "div.h9 { font-size: 24px; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px; "^
+          "text-align: center; background-color: #a3daff; "^
+          "padding: 2px; }" ;
+
+          "a { color: #416dff; text-decoration: none; }";
+          "a:hover { text-decoration: underline; }" ;
+          (* keep defaults for <pre> *)
+
+          ".deprecated { color: #808080; font-style: italic; }" ;
+
+          "ul.indexlist { margin-left: 0; padding-left: 0;}" ;
+          "ul.indexlist li { list-style-type: none ; margin-left: 0; padding-left: 0; }" ;
+        ]
+      else
+        [ ".keyword { font-weight : bold ; color : Red }" ;
+          ".keywordsign { color : #C04600 }" ;
+          ".superscript { font-size : 4 }" ;
+          ".subscript { font-size : 4 }" ;
+          ".comment { color : Green }" ;
+          ".constructor { color : Blue }" ;
+          ".type { color : #5C6585 }" ;
+          ".string { color : Maroon }" ;
+          ".warning { color : Red ; font-weight : bold }" ;
+          ".info { margin-left : 3em; margin-right: 3em }" ;
+          ".param_info { margin-top: 4px; margin-left : 3em; margin-right : 3em }" ;
+          ".code { color : #465F91 ; }" ;
+          ".typetable { border-style : hidden }" ;
+          ".paramstable { border-style : hidden ; padding: 5pt 5pt}" ;
+          "tr { background-color : White }" ;
+          "td.typefieldcomment { background-color : #FFFFFF ; font-size: smaller ;}" ;
+          "div.sig_block {margin-left: 2em}" ;
+          "*:target { background: yellow; }" ;
+
+          "body {font: 13px sans-serif; color: black; text-align: left; padding: 5px; margin: 0}";
+
+          "h1 { font-size : 20pt ; text-align: center; }" ;
+
+          "h2 { font-size : 20pt ; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px;"^
+          "text-align: center; background-color: #90BDFF ;"^
+          "padding: 2px; }" ;
+
+          "h3 { font-size : 20pt ; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px;"^
+          "text-align: center; background-color: #90DDFF ;"^
+          "padding: 2px; }" ;
+
+          "h4 { font-size : 20pt ; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px;"^
+          "text-align: center; background-color: #90EDFF ;"^
+          "padding: 2px; }" ;
+
+          "h5 { font-size : 20pt ; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px;"^
+          "text-align: center; background-color: #90FDFF ;"^
+          "padding: 2px; }" ;
+
+          "h6 { font-size : 20pt ; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px;"^
+          "text-align: center; background-color: #90BDFF ; "^
+          "padding: 2px; }" ;
+
+          "div.h7 { font-size : 20pt ; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px;"^
+          "text-align: center; background-color: #E0FFFF ; "^
+          "padding: 2px; }" ;
+
+          "div.h8 { font-size : 20pt ; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px;"^
+          "text-align: center; background-color: #F0FFFF ; "^
+          "padding: 2px; }" ;
+
+          "div.h9 { font-size : 20pt ; border: 1px solid #000000; "^
+          "margin-top: 5px; margin-bottom: 2px;"^
+          "text-align: center; background-color: #FFFFFF ; "^
+          "padding: 2px; }" ;
+
+          "a {color: #416DFF; text-decoration: none}";
+          "a:hover {background-color: #ddd; text-decoration: underline}";
+          "pre { margin-bottom: 4px; font-family: monospace; }" ;
+          "pre.verbatim, pre.codepre { }";
+
+          ".indextable {border: 1px #ddd solid; border-collapse: collapse}";
+          ".indextable td, .indextable th {border: 1px #ddd solid; min-width: 80px}";
+          ".indextable td.module {background-color: #eee ;  padding-left: 2px; padding-right: 2px}";
+          ".indextable td.module a {color: 4E6272; text-decoration: none; display: block; width: 100%}";
+          ".indextable td.module a:hover {text-decoration: underline; background-color: transparent}";
+          ".deprecated {color: #888; font-style: italic}" ;
+
+          ".indextable tr td div.info { margin-left: 2px; margin-right: 2px }" ;
+
+          "ul.indexlist { margin-left: 0; padding-left: 0;}";
+          "ul.indexlist li { list-style-type: none ; margin-left: 0; padding-left: 0; }";
+        ]
 
     (** The style file for all pages. *)
     val mutable style_file = "style.css"
@@ -961,7 +1300,12 @@
       | Some f ->
           style_file <- f
       );
-      style <- "<link rel=\"stylesheet\" href=\""^style_file^"\" type=\"text/css\">\n"
+      let style_sheet href =
+        Printf.sprintf "<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n" href in
+      if !html5 then
+        style <- (style_sheet bootstrap_css) ^ (style_sheet style_file)
+      else
+        style <- style_sheet style_file
 
     (** Get the title given by the user *)
     method title = match !Global.title with None -> "" | Some t -> self#escape t
@@ -1085,24 +1429,32 @@
        match pre with
          None -> ()
        | Some name ->
-           bp b "<a class=\"pre\" href=\"%s\" title=\"%s\">%s</a>\n"
+           bp b "<a class=\"pre\" href=\"%s\" title=\"%s\">%s%s</a>\n"
              (fst (Naming.html_files name))
              name
+             (if_html5 "<span class=\"glyphicon glyphicon-chevron-left\"></span>&nbsp;" "")
              Odoc_messages.previous
       );
       bs b "&nbsp;";
+      if !html5 then bs b "&nbsp;";
       let father = Name.father name in
       let href = if father = "" then self#index else fst (Naming.html_files father) in
       let father_name = if father = "" then "Index" else father in
-      bp b "<a class=\"up\" href=\"%s\" title=\"%s\">%s</a>\n" href father_name Odoc_messages.up;
+      bp b "<a class=\"up\" href=\"%s\" title=\"%s\">%s%s</a>\n"
+        href
+        father_name
+        (if_html5 "<span class=\"glyphicon glyphicon-chevron-up\"></span>&nbsp;" "")
+        Odoc_messages.up;
       bs b "&nbsp;";
+      if !html5 then bs b "&nbsp;";
       (
        match post with
          None -> ()
        | Some name ->
-           bp b "<a class=\"post\" href=\"%s\" title=\"%s\">%s</a>\n"
+           bp b "<a class=\"post\" href=\"%s\" title=\"%s\">%s%s</a>\n"
              (fst (Naming.html_files name))
              name
+             (if_html5 "<span class=\"glyphicon glyphicon-chevron-right\"></span>&nbsp;" "")
              Odoc_messages.next
       );
       bs b "</div>\n"
@@ -1119,10 +1471,18 @@
       try
         let chanout = open_out file in
         let b = new_buf () in
+        bs b (if_html5 doctype "");
         bs b "<html>";
         self#print_header b (self#inner_title in_title);
-        bs b"<body>\n";
+        if !html5 then begin
+          bs b "<style>\n";
+          bs b ".code { background-color: #ffffff; }";
+          bs b "</style>\n";
+        end;
+        bs b "<body>\n";
+        bs b (open_container ());
         self#html_of_code b code;
+        bs b (close_container ());
         bs b "</body></html>";
         Buffer.output_buffer chanout b;
         close_out chanout
@@ -1154,12 +1514,60 @@
           else
             s_final
       in
+      let extract_class_name s =
+        let len = String.length s in
+        let ocaml_name = Buffer.create len in
+        let java_name = Buffer.create len in
+        let i = ref 0 in
+        while (!i < len) && (s.[!i] <> ' ') && (s.[!i] <> '\t') do
+          begin match s.[!i] with
+          | '\'' ->
+              if s.[succ !i] = '\'' then begin
+                Buffer.add_char ocaml_name '\'';
+                Buffer.add_char ocaml_name '\'';
+                Buffer.add_char java_name '.';
+                i := !i + 2
+              end else begin
+                Buffer.add_char ocaml_name '\'';
+                Buffer.add_char java_name '/';
+                incr i
+              end
+          | ch ->
+              Buffer.add_char ocaml_name ch;
+              Buffer.add_char java_name ch;
+              incr i
+          end;
+        done;
+        let suffix = Buffer.create len in
+        while (!i < len) do
+          Buffer.add_char suffix s.[!i];
+          incr i
+        done;
+        Buffer.contents ocaml_name,
+        Buffer.contents java_name,
+        Buffer.contents suffix in
+      let g str_t =
+        let match_s = Str.matched_string str_t in
+        let ocaml_name, java_name, kind =
+          extract_class_name match_s in
+        if (String.length ocaml_name > 0) && (ocaml_name.[0] <> '\'') then begin
+          let url_base = base_url_of_class java_name in
+          Printf.sprintf "<a href=\"%s%s.html\">%s%s</a>"
+            url_base java_name ocaml_name kind
+        end else
+          match_s
+      in
       let s2 = Str.global_substitute
           (Str.regexp "\\([A-Z]\\([a-zA-Z_'0-9]\\)*\\.\\)+\\([a-z][a-zA-Z_'0-9]*\\)")
           f
           s
       in
-      s2
+      let s3 = Str.global_substitute
+          (Str.regexp "[a-zA-Z_'0-9]*[ \t]+java_\\(\\(instance\\)\\|\\(extends\\)\\)")
+          g
+          s2
+      in
+      s3
 
     (** Take a string and return the string where fully qualified module idents
        have been replaced by links to the module referenced by the ident.*)
@@ -1189,9 +1597,9 @@
     method html_of_type_expr b m_name t =
       let s = Odoc_info.remove_ending_newline (Odoc_info.string_of_type_expr t) in
       let s2 = newline_to_indented_br s in
-      bs b "<code class=\"type\">";
+      bs b (open_type ());
       bs b (self#create_fully_qualified_idents_links m_name s2);
-      bs b "</code>"
+      bs b (close_type ())
 
     (** Print html code to display a [Types.type_expr list]. *)
     method html_of_type_expr_list ?par b m_name sep l =
@@ -1200,47 +1608,52 @@
       print_DEBUG "html#html_of_type_expr_list: 1";
       let s2 = newline_to_indented_br s in
       print_DEBUG "html#html_of_type_expr_list: 2";
-      bs b "<code class=\"type\">";
+      bs b (open_type ());
       bs b (self#create_fully_qualified_idents_links m_name s2);
-      bs b "</code>"
+      bs b (close_type ())
 
     (** Print html code to display a [Types.type_expr list] as type parameters
        of a class of class type. *)
     method html_of_class_type_param_expr_list b m_name l =
       let s = Odoc_info.string_of_class_type_param_list l in
       let s2 = newline_to_indented_br s in
-      bs b "<code class=\"type\">[";
+      bs b (open_type ());
+      bs b "[";
       bs b (self#create_fully_qualified_idents_links m_name s2);
-      bs b "]</code>"
+      bs b "]";
+      bs b (close_type ())
 
     method html_of_class_parameter_list b father c =
       let s = Odoc_info.string_of_class_params c in
       let s = Odoc_info.remove_ending_newline s in
       let s2 = newline_to_indented_br s in
-      bs b "<code class=\"type\">";
+      bs b (open_type ());
       bs b (self#create_fully_qualified_idents_links father s2);
-      bs b "</code>"
+      bs b (close_type ())
 
     (** Print html code to display a list of type parameters for the given type.*)
     method html_of_type_expr_param_list b m_name t =
       let s = Odoc_info.string_of_type_param_list t in
       let s2 = newline_to_indented_br s in
-      bs b "<code class=\"type\">";
+      bs b (open_type ());
       bs b (self#create_fully_qualified_idents_links m_name s2);
-      bs b "</code>"
+      bs b (close_type ())
 
     (** Print html code to display a [Types.module_type]. *)
     method html_of_module_type b ?code m_name t =
       let s = Odoc_info.remove_ending_newline (Odoc_info.string_of_module_type ?code t) in
-      bs b "<code class=\"type\">";
+      bs b (open_type ());
       bs b (self#create_fully_qualified_module_idents_links m_name s);
-      bs b "</code>"
+      bs b (close_type ())
 
     (** Print html code to display the given module kind. *)
     method html_of_module_kind b father ?modu kind =
       match kind with
         Module_struct eles ->
-          self#html_of_text b [Code "sig"];
+          if !html5 then
+            bs b "<tt>sig</tt>"
+          else
+            self#html_of_text b [Code "sig"];
           (
            match modu with
              None ->
@@ -1251,11 +1664,14 @@
                let (html_file, _) = Naming.html_files m.m_name in
                bp b " <a href=\"%s\">..</a> " html_file
           );
-          self#html_of_text b [Code "end"]
+          if !html5 then
+            bs b "<tt>end</tt>"
+          else
+            self#html_of_text b [Code "end"]
       | Module_alias a ->
-          bs b "<code class=\"type\">";
+          bs b (open_type ());
           bs b (self#create_fully_qualified_module_idents_links father a.ma_name);
-          bs b "</code>"
+          bs b (close_type ())
       | Module_functor (p, k) ->
           if !html_short_functors then
             bs b " "
@@ -1276,24 +1692,31 @@
           (* TODO: l'application n'est pas correcte dans un .mli.
              Que faire ? -> afficher le module_type du typedtree  *)
           self#html_of_module_kind b father k1;
-          self#html_of_text b [Code "("];
+          if !html5 then
+            bs b "<tt>(</tt>"
+          else
+            self#html_of_text b [Code "("];
           self#html_of_module_kind b father k2;
-          self#html_of_text b [Code ")"]
+          if !html5 then
+            bs b "<tt>)</tt>"
+          else
+            self#html_of_text b [Code ")"]
       | Module_with (k, s) ->
           (* TODO: modify when Module_with will be more detailed *)
           self#html_of_module_type_kind b father ?modu k;
-          bs b "<code class=\"type\"> ";
+          bs b (open_type ());
           bs b (self#create_fully_qualified_module_idents_links father s);
-          bs b "</code>"
+          bs b (close_type ())
       | Module_constraint (k, tk) ->
           (* TODO: on affiche quoi ? *)
           self#html_of_module_kind b father ?modu k
       | Module_typeof s ->
-          bs b "<code class=\"type\">module type of ";
+          bs b (open_type ());
+          bs b "module type of ";
           bs b (self#create_fully_qualified_module_idents_links father s);
-          bs b "</code>"
+          bs b (close_type ())
       | Module_unpack (code, mta) ->
-          bs b "<code class=\"type\">";
+          bs b (open_type ());
           begin
             match mta.mta_module with
               None ->
@@ -1302,7 +1725,7 @@
                 let (html_file, _) = Naming.html_files mt.mt_name in
                 bp b " <a href=\"%s\">%s</a> " html_file (self#escape code)
           end;
-          bs b "</code>"
+          bs b (close_type ())
 
 
     method html_of_module_parameter b father p =
@@ -1312,14 +1735,28 @@
         else
           "functor ", "-> "
       in
-      self#html_of_text b
-        [
-          Code (s_functor^"(");
-          Code p.mp_name ;
-          Code " : ";
-        ] ;
+      if !html5 then begin
+        bs b "<tt>";
+        bs b s_functor;
+        bs b "(";
+        bs b p.mp_name;
+        bs b " : ";
+        bs b "</tt>"
+      end else
+        self#html_of_text b
+          [
+           Code (s_functor^"(");
+           Code p.mp_name ;
+           Code " : ";
+         ] ;
       self#html_of_module_type_kind b father p.mp_kind;
-      self#html_of_text b [ Code (") "^s_arrow)]
+      if !html5 then begin
+        bs b "<tt>";
+        bs b ") ";
+        bs b s_arrow;
+        bs b "</tt>"
+      end else
+        self#html_of_text b [ Code (") "^s_arrow)]
 
     method html_of_module_element b father ele =
       match ele with
@@ -1346,7 +1783,10 @@
     method html_of_module_type_kind b father ?modu ?mt kind =
       match kind with
         Module_type_struct eles ->
-          self#html_of_text b [Code "sig"];
+          if !html5 then
+            bs b "<tt>sig</tt>"
+          else
+            self#html_of_text b [Code "sig"];
           (
            match mt with
              None ->
@@ -1364,23 +1804,27 @@
                let (html_file, _) = Naming.html_files mt.mt_name in
                bp b " <a href=\"%s\">..</a> " html_file
           );
-          self#html_of_text b [Code "end"]
+          if !html5 then
+            bs b "<tt>end</tt>"
+          else
+            self#html_of_text b [Code "end"]
       | Module_type_functor (p, k) ->
           self#html_of_module_parameter b father p;
           self#html_of_module_type_kind b father ?modu ?mt k
       | Module_type_alias a ->
-          bs b "<code class=\"type\">";
+          bs b (open_type ());
           bs b (self#create_fully_qualified_module_idents_links father a.mta_name);
-          bs b "</code>"
+          bs b (close_type ())
       | Module_type_with (k, s) ->
           self#html_of_module_type_kind b father ?modu ?mt k;
-          bs b "<code class=\"type\"> ";
+          bs b (open_type ());
           bs b (self#create_fully_qualified_module_idents_links father s);
-          bs b "</code>"
+          bs b (close_type ())
       | Module_type_typeof s ->
-          bs b "<code class=\"type\">module type of ";
+          bs b (open_type ());
+          bs b "module type of ";
           bs b (self#create_fully_qualified_module_idents_links father s);
-          bs b "</code>"
+          bs b (close_type ())
 
     (** Print html code to display the type of a module parameter.. *)
     method html_of_module_parameter_type b m_name p =
@@ -1399,7 +1843,7 @@
     (** Print html code for a value. *)
     method html_of_value b v =
       Odoc_info.reset_type_names ();
-      bs b "\n<pre>" ;
+      bp b "\n%s" (open_fixed ());
       bp b "<span id=\"%s\">" (Naming.value_target v);
       bs b (self#keyword "val");
       bs b " ";
@@ -1414,7 +1858,7 @@
       bs b "</span>";
       bs b " : ";
       self#html_of_type_expr b (Name.father v.val_name) v.val_type;
-      bs b "</pre>";
+      bs b (close_fixed ());
       self#html_of_info b v.val_info;
       (
        if !with_parameter_list then
@@ -1426,7 +1870,7 @@
     (** Print html code for an exception. *)
     method html_of_exception b e =
       Odoc_info.reset_type_names ();
-      bs b "\n<pre>";
+      bp b "\n%s" (open_fixed ());
       bp b "<span id=\"%s\">" (Naming.exception_target e);
       bs b (self#keyword "exception");
       bs b " ";
@@ -1452,7 +1896,7 @@
                 bp b "<a href=\"%s\">%s</a>" (Naming.complete_exception_target e) e.ex_name
            )
       );
-      bs b "</pre>\n";
+      bp b "%s\n" (close_fixed ());
       self#html_of_info b e.ex_info
 
     (** Print html code for a type. *)
@@ -1461,12 +1905,12 @@
       let father = Name.father t.ty_name in
       bs b
         (match t.ty_manifest, t.ty_kind with
-          None, Type_abstract -> "\n<pre>"
+          None, Type_abstract -> "\n" ^ (open_fixed ())
         | None, Type_variant _
-        | None, Type_record _ -> "\n<pre><code>"
-        | Some _, Type_abstract -> "\n<pre>"
+        | None, Type_record _ -> "\n"  ^ (if_html5 "<tt><tt>" "<pre><code>")
+        | Some _, Type_abstract -> "\n" ^ (open_fixed ())
         | Some _, Type_variant _
-        | Some _, Type_record _ -> "\n<pre>"
+        | Some _, Type_record _ -> "\n" ^ (open_fixed ())
         );
       bp b "<span id=\"%s\">" (Naming.type_target t);
       bs b ((self#keyword "type")^" ");
@@ -1485,23 +1929,25 @@
            bs b " "
       );
       (match t.ty_kind with
-        Type_abstract -> bs b "</pre>"
+        Type_abstract -> bs b (close_fixed ())
       | Type_variant l ->
           bs b "= ";
           if priv then bs b "private ";
           bs b
             (
              match t.ty_manifest with
-               None -> "</code></pre>"
-             | Some _ -> "</pre>"
+               None -> if_html5 "</tt></tt>" "</code></pre>"
+             | Some _ -> (close_fixed ())
             );
           bs b "<table class=\"typetable\">\n";
           let print_one constr =
             bs b "<tr>\n<td align=\"left\" valign=\"top\" >\n";
-            bs b "<code>";
+            bs b (if_html5 "<tt>" "<code>");
             bs b (self#keyword "|");
-            bs b "</code></td>\n<td align=\"left\" valign=\"top\" >\n";
-            bs b "<code>";
+            bs b (if_html5 "</tt>" "</code>");
+            bs b "</td>\n<td align=\"left\" valign=\"top\" >\n";
+            bs b (if_html5 "<tt>" "<code>");
+            bs b (if_html5 "&nbsp;" "");
             bp b "<span id=\"%s\">%s</span>"
               (Naming.const_target t constr)
               (self#constructor constr.vc_name);
@@ -1520,22 +1966,25 @@
                  bs b (" " ^ (self#keyword "->") ^ " ");
                  self#html_of_type_expr b father r;
             );
-            bs b "</code></td>\n";
+            bs b (if_html5 "</tt>" "</code>");
+            bs b "</td>\n";
             (
              match constr.vc_text with
                None -> ()
              | Some t ->
                  bs b "<td class=\"typefieldcomment\" align=\"left\" valign=\"top\" >";
-                 bs b "<code>";
+                 bs b (if_html5 "<tt>" "<code>");
                  bs b "(*";
-                 bs b "</code></td>";
+                 bs b (if_html5 "</tt>" "</code>");
+                 bs b "</td>";
                  bs b "<td class=\"typefieldcomment\" align=\"left\" valign=\"top\" >";
                  self#html_of_text b t;
                  bs b "</td>";
                  bs b "<td class=\"typefieldcomment\" align=\"left\" valign=\"bottom\" >";
-                 bs b "<code>";
+                 bs b (if_html5 "<tt>" "<code>");
                  bs b "*)";
-                 bs b "</code></td>";
+                 bs b (if_html5 "</tt>" "</code>");
+                 bs b "</td>";
             );
             bs b "\n</tr>"
           in
@@ -1549,33 +1998,37 @@
           bs b
             (
              match t.ty_manifest with
-               None -> "</code></pre>"
-             | Some _ -> "</pre>"
+               None -> if_html5 "</tt></tt>" "</code></pre>"
+             | Some _ -> (close_fixed ())
             );
           bs b "<table class=\"typetable\">\n" ;
           let print_one r =
             bs b "<tr>\n<td align=\"left\" valign=\"top\" >\n";
-            bs b "<code>&nbsp;&nbsp;</code>";
+            bs b (if_html5 "<tt>&nbsp;&nbsp;</tt>"
+                           "<code>&nbsp;&nbsp;</code>");
             bs b "</td>\n<td align=\"left\" valign=\"top\" >\n";
-            bs b "<code>";
+            bs b (if_html5 "<tt>" "<code>");
             if r.rf_mutable then bs b (self#keyword "mutable&nbsp;") ;
             bp b "<span id=\"%s\">%s</span>&nbsp;: "
               (Naming.recfield_target t r)
               r.rf_name;
             self#html_of_type_expr b father r.rf_type;
-            bs b ";</code></td>\n";
+            bs b ";";
+            bs b (if_html5 "</tt>" "</code>");
+            bs b "</td>\n";
             (
              match r.rf_text with
                None -> ()
              | Some t ->
                  bs b "<td class=\"typefieldcomment\" align=\"left\" valign=\"top\" >";
-                 bs b "<code>";
+                 bs b (if_html5 "<tt>" "<code>");
                  bs b "(*";
-                 bs b "</code></td>";
+                 bs b (if_html5 "</tt></td>" "</code></td>");
                  bs b "<td class=\"typefieldcomment\" align=\"left\" valign=\"top\" >";
                  self#html_of_text b t;
                  bs b "</td><td class=\"typefieldcomment\" align=\"left\" valign=\"bottom\" >";
-                 bs b "<code>*)</code></td>";
+                 bs b (if_html5 "<tt>*)</tt></td>"
+                                "<code>*)</code></td>");
             );
             bs b "\n</tr>"
           in
@@ -1589,7 +2042,7 @@
     (** Print html code for a class attribute. *)
     method html_of_attribute b a =
       let module_name = Name.father (Name.father a.att_value.val_name) in
-      bs b "\n<pre>" ;
+      bp b "\n%s" (open_fixed ());
       bp b "<span id=\"%s\">" (Naming.attribute_target a);
       bs b (self#keyword "val");
       bs b " ";
@@ -1615,13 +2068,13 @@
       bs b "</span>";
       bs b " : ";
       self#html_of_type_expr b module_name a.att_value.val_type;
-      bs b "</pre>";
+      bs b (close_fixed ());
       self#html_of_info b a.att_value.val_info
 
     (** Print html code for a class method. *)
     method html_of_method b m =
       let module_name = Name.father (Name.father m.met_value.val_name) in
-      bs b "\n<pre>";
+      bp b "\n%s" (open_fixed ());
       (* html mark *)
       bp b "<span id=\"%s\">" (Naming.method_target m);
      bs b ((self#keyword "method")^" ");
@@ -1638,7 +2091,7 @@
       bs b "</span>";
       bs b " : ";
       self#html_of_type_expr b module_name m.met_value.val_type;
-      bs b "</pre>";
+      bs b (close_fixed ());
       self#html_of_info b m.met_value.val_info;
       (
        if !with_parameter_list then
@@ -1671,9 +2124,9 @@
             match Parameter.desc_by_name p n with
               None -> ()
             | Some t ->
-                bs b "<code>";
+                bs b (if_html5 "<tt>" "<code>");
                 bs b n;
-                bs b "</code> : ";
+                bs b (if_html5 "</tt> : " "</code> : ");
                 self#html_of_text b t
           in
           print_concat b "<br>\n" print_one l2
@@ -1686,9 +2139,9 @@
           bs b "<div class=\"param_info\">";
           bs b "<table border=\"0\" cellpadding=\"3\" width=\"100%\">\n";
           bs b "<tr>\n<td align=\"left\" valign=\"top\" width=\"1%\">";
-          bs b "<b>";
+          bs b (open_bold ());
           bs b Odoc_messages.parameters;
-          bs b ": </b></td>\n" ;
+          bp b ": %s</td>\n" (close_bold ());
           bs b "<td>\n<table class=\"paramstable\">\n";
           let print_one p =
             bs b "<tr>\n<td align=\"center\" valign=\"top\" width=\"15%\" class=\"code\">\n";
@@ -1719,9 +2172,11 @@
           l
       in
       let f p =
-        bs b "<div class=\"param_info\"><code class=\"code\">";
+        bs b "<div class=\"param_info\">";
+        bs b (open_type ());
         bs b (Parameter.complete_name p);
-        bs b "</code> : " ;
+        bs b (close_type ()) ;
+        bs b " : " ;
         self#html_of_parameter_description b p;
         bs b "</div>\n"
       in
@@ -1735,16 +2190,17 @@
       | _ ->
           bs b "<table border=\"0\" cellpadding=\"3\" width=\"100%\">\n";
           bs b "<tr>\n";
-          bs b "<td align=\"left\" valign=\"top\" width=\"1%%\"><b>";
+          bp b "<td align=\"left\" valign=\"top\" width=\"1%%\">%s" (open_bold ());
           bs b Odoc_messages.parameters ;
-          bs b ": </b></td>\n<td>\n";
+          bp b ": %s</td>\n<td>\n" (close_bold ());
           bs b "<table class=\"paramstable\">\n";
           List.iter
             (fun (p, desc_opt) ->
               bs b "<tr>\n";
-              bs b "<td align=\"center\" valign=\"top\" width=\"15%\">\n<code>" ;
+              bs b (if_html5 "<td align=\"center\" valign=\"top\" width=\"15%\">\n<tt>"
+                             "<td align=\"center\" valign=\"top\" width=\"15%\">\n<code>") ;
               bs b p.mp_name;
-              bs b "</code></td>\n" ;
+              bs b (if_html5 "</tt></td>\n" "</code></td>\n") ;
               bs b "<td align=\"center\" valign=\"top\">:</td>\n";
               bs b "<td>" ;
               self#html_of_module_parameter_type b m_name p;
@@ -1765,7 +2221,7 @@
     method html_of_module b ?(info=true) ?(complete=true) ?(with_link=true) m =
       let (html_file, _) = Naming.html_files m.m_name in
       let father = Name.father m.m_name in
-      bs b "\n<pre>";
+      bp b "\n%s" (open_fixed ());
       bs b ((self#keyword "module")^" ");
       (
        if with_link then
@@ -1780,7 +2236,7 @@
        | _ -> bs b ": "
       );
       self#html_of_module_kind b father ~modu: m m.m_kind;
-      bs b "</pre>";
+      bs b (close_fixed ());
       if info then
         (
          if complete then
@@ -1795,7 +2251,7 @@
     method html_of_modtype b ?(info=true) ?(complete=true) ?(with_link=true) mt =
       let (html_file, _) = Naming.html_files mt.mt_name in
       let father = Name.father mt.mt_name in
-      bs b "\n<pre>";
+      bp b "\n%s" (open_fixed ());
       bs b ((self#keyword "module type")^" ");
       (
        if with_link then
@@ -1809,7 +2265,7 @@
           bs b " = ";
           self#html_of_module_type_kind b father ~mt k
       );
-      bs b "</pre>";
+      bs b (close_fixed ());
       if info then
         (
          if complete then
@@ -1822,7 +2278,7 @@
 
     (** Print html code for an included module. *)
     method html_of_included_module b im =
-      bs b "\n<pre>";
+      bp b "\n%s" (open_fixed ());
       bs b ((self#keyword "include")^" ");
       (
        match im.im_module with
@@ -1840,7 +2296,7 @@
            in
            bp b "<a href=\"%s\">%s</a>" file name
       );
-      bs b "</pre>\n";
+      bp b "%s\n" (close_fixed ());
       self#html_of_info b im.im_info
 
     method html_of_class_element b element =
@@ -1855,7 +2311,10 @@
     method html_of_class_kind b father ?cl kind =
       match kind with
         Class_structure (inh, eles) ->
-          self#html_of_text b [Code "object"];
+          if !html5 then
+            bs b "<tt>object</tt>"
+          else
+            self#html_of_text b [Code "object"];
           (
            match cl with
              None ->
@@ -1871,7 +2330,10 @@
                let (html_file, _) = Naming.html_files cl.cl_name in
                bp b " <a href=\"%s\">..</a> " html_file
           );
-          self#html_of_text b [Code "end"]
+          if !html5 then
+            bs b "<tt>end</tt>"
+          else
+            self#html_of_text b [Code "end"]
 
       | Class_apply capp ->
           (* TODO: display final type from typedtree *)
@@ -1885,16 +2347,25 @@
                self#html_of_class_type_param_expr_list b father l;
                bs b " "
           );
-          bs b "<code class=\"type\">";
+          bs b (open_type ());
           bs b (self#create_fully_qualified_idents_links father cco.cco_name);
-          bs b "</code>"
+          bs b (close_type ())
 
       | Class_constraint (ck, ctk) ->
-          self#html_of_text b [Code "( "] ;
+          if !html5 then
+            bs b "<tt>( </tt>"
+          else
+            self#html_of_text b [Code "( "] ;
           self#html_of_class_kind b father ck;
-          self#html_of_text b [Code " : "] ;
+          if !html5 then
+            bs b "<tt> : </tt>"
+          else
+            self#html_of_text b [Code " : "] ;
           self#html_of_class_type_kind b father ctk;
-          self#html_of_text b [Code " )"]
+          if !html5 then
+            bs b "<tt> )</tt>"
+          else
+            self#html_of_text b [Code " )"]
 
     method html_of_class_type_kind b father ?ct kind =
       match kind with
@@ -1906,12 +2377,15 @@
                self#html_of_class_type_param_expr_list b father l;
                bs b " "
           );
-          bs b "<code class=\"type\">";
+          bs b (open_type ());
           bs b (self#create_fully_qualified_idents_links father cta.cta_name);
-          bs b "</code>"
+          bs b (close_type ())
 
       | Class_signature (inh, eles) ->
-          self#html_of_text b [Code "object"];
+          if !html5 then
+            bs b "<tt>object</tt>"
+          else
+            self#html_of_text b [Code "object"];
           (
            match ct with
              None ->
@@ -1926,14 +2400,17 @@
                let (html_file, _) = Naming.html_files ct.clt_name in
                bp b " <a href=\"%s\">..</a> " html_file
           );
-          self#html_of_text b [Code "end"]
+          if !html5 then
+            bs b "<tt>end</tt>"
+          else
+            self#html_of_text b [Code "end"]
 
     (** Print html code for a class. *)
     method html_of_class b ?(complete=true) ?(with_link=true) c =
       let father = Name.father c.cl_name in
       Odoc_info.reset_type_names ();
       let (html_file, _) = Naming.html_files c.cl_name in
-      bs b "\n<pre>";
+      bp b "\n%s" (open_fixed ());
       (* we add a html id, the same as for a type so we can
          go directly here when the class name is used as a type name *)
       bp b "<span name=\"%s\">"
@@ -1966,7 +2443,7 @@
       bs b " : " ;
       self#html_of_class_parameter_list b father c ;
       self#html_of_class_kind b father ~cl: c c.cl_kind;
-      bs b "</pre>" ;
+      bs b (close_fixed ()) ;
       print_DEBUG "html#html_of_class : info" ;
       (
        if complete then
@@ -1980,7 +2457,7 @@
       Odoc_info.reset_type_names ();
       let father = Name.father ct.clt_name in
       let (html_file, _) = Naming.html_files ct.clt_name in
-      bs b "\n<pre>";
+      bp b "\n%s" (open_fixed ());
       (* we add a html id, the same as for a type so we can
          go directly here when the class type name is used as a type name *)
       bp b "<span id=\"%s\">"
@@ -2010,7 +2487,7 @@
       bs b "</span>";
       bs b " = ";
       self#html_of_class_type_kind b father ~ct ct.clt_kind;
-      bs b "</pre>";
+      bs b (close_fixed ());
       (
        if complete then
          self#html_of_info ~cls: "classtype top" ~indent: true
@@ -2123,9 +2600,11 @@
       try
         let chanout = open_out (Filename.concat !Global.target_dir simple_file) in
         let b = new_buf () in
+        bs b (if_html5 doctype "");
         bs b "<html>\n";
         self#print_header b (self#inner_title title);
         bs b "<body>\n";
+        bs b (open_container ());
         self#print_navbar b None None "";
         bs b "<h1>";
         bs b title;
@@ -2157,12 +2636,14 @@
               in
               bs b "<tr><td align=\"left\"><br>";
               bs b s ;
-              bs b "</td></tr>\n" ;
+              bs b "</td><td>&nbsp;</td></tr>\n" ;
               List.iter f_ele l
         in
-        bs b "<table>\n";
+        bs b (if_html5 "<table class=\"table table-condensed table-hover\">\n"
+                       "<table>\n");
         List.iter f_group groups ;
         bs b "</table>\n" ;
+        bs b (close_container ());
         bs b "</body>\n</html>";
         Buffer.output_buffer chanout b;
         close_out chanout
@@ -2200,6 +2681,7 @@
           ~comments: (Class.class_comments cl)
           (self#inner_title cl.cl_name);
         bs b "<body>\n";
+        bs b (open_container ());
         self#print_navbar b pre_name post_name cl.cl_name;
         bs b "<h1>";
         bs b (Odoc_messages.clas^" ");
@@ -2217,6 +2699,7 @@
         (* the various elements *)
         List.iter (self#html_of_class_element b)
           (Class.class_elements ~trans:false cl);
+        bs b (close_container ());
         bs b "</body></html>";
         Buffer.output_buffer chanout b;
         close_out chanout;
@@ -2248,6 +2731,7 @@
           (self#inner_title clt.clt_name);
 
         bs b "<body>\n";
+        bs b (open_container ());
         self#print_navbar b pre_name post_name clt.clt_name;
         bs b "<h1>";
         bs b (Odoc_messages.class_type^" ");
@@ -2263,6 +2747,7 @@
         (* the various elements *)
         List.iter (self#html_of_class_element b)
           (Class.class_type_elements ~trans: false clt);
+        bs b (close_container ());
         bs b "</body></html>";
         Buffer.output_buffer chanout b;
         close_out chanout;
@@ -2293,6 +2778,7 @@
           ~comments: (Module.module_type_comments mt)
           (self#inner_title mt.mt_name);
         bs b "<body>\n";
+        bs b (open_container ());
         self#print_navbar b pre_name post_name mt.mt_name;
         bp b "<h1>";
         bs b (Odoc_messages.module_type^" ");
@@ -2312,9 +2798,14 @@
         bs b "<hr width=\"100%\">\n";
         (* module elements *)
         List.iter
-          (self#html_of_module_element b (Name.father mt.mt_name))
+          (fun x ->
+            bs b (open_row ());
+            self#html_of_module_element b (Name.father mt.mt_name) x;
+            bs b (close_row ());
+            bs b (empty_row ()))
           (Module.module_type_elements mt);
 
+        bs b (close_container ());
         bs b "</body></html>";
         Buffer.output_buffer chanout b;
         close_out chanout;
@@ -2361,6 +2852,7 @@
           ~comments: (Module.module_comments modu)
           (self#inner_title modu.m_name);
         bs b "<body>\n" ;
+        bs b (open_container ());
         self#print_navbar b pre_name post_name modu.m_name ;
         bs b "<h1>";
         if modu.m_text_only then
@@ -2395,9 +2887,14 @@
 
         (* module elements *)
         List.iter
-          (self#html_of_module_element b (Name.father modu.m_name))
+          (fun x ->
+            bs b (open_row ());
+            self#html_of_module_element b (Name.father modu.m_name) x;
+            bs b (close_row ());
+            bs b (empty_row ()))
           (Module.module_elements modu);
 
+        bs b (close_container ());
         bs b "</body></html>";
         Buffer.output_buffer chanout b;
         close_out chanout;
@@ -2439,6 +2936,7 @@
         bs b "<html>\n";
         self#print_header b self#title;
         bs b "<body>\n";
+        bs b (open_container ());
 
         bs b "<h1>";
         bs b title;
@@ -2456,6 +2954,7 @@
                (List.map (fun m -> m.m_name) module_list);
          | Some i -> self#html_of_info ~indent: false b info
         );
+        bs b (close_container ());
         bs b "</body>\n</html>";
         Buffer.output_buffer chanout b;
         close_out chanout
@@ -2608,6 +3107,30 @@
       if not !index_only then
         self#generate_elements self#generate_for_module module_list ;
 
+      (* copy Bootstrap files if needed *)
+      let copy_file src dst =
+        let src = open_in_bin src in
+        let dst = open_out_bin dst in
+        let len = 4096 in
+        let buff = String.create len in
+        let read = ref (input src buff 0 len) in
+        while (!read <> 0) do
+          output dst buff 0 !read;
+          read := input src buff 0 len
+        done;
+        close_in_noerr src;
+        close_out_noerr dst in
+      if !html5 then begin
+        List.iter
+          (fun file ->
+            let ocamldoc_dir = Filename.concat Config.standard_library "ocamldoc" in
+            let bootstrap_dir = Filename.concat ocamldoc_dir "bootstrap" in
+            let src = Filename.concat bootstrap_dir file in
+            let dst = Filename.concat !Global.target_dir file in
+            copy_file src dst)
+          bootstrap_files
+      end;
+
       try
         self#generate_index module_list;
         self#generate_values_index module_list ;
