diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index a5b403a9b..cb8bd35d3 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -492,10 +492,10 @@ inlineToHtml opts inline =
                         htmlContents <- blockListToNote opts ref contents 
                         -- push contents onto front of notes
                         put $ st {stNotes = (htmlContents:notes)} 
-                        return $ anchor ! [href ("#" ++ writerIdentifierPrefix opts ++ "fn" ++ ref),
-                                          theclass "footnoteRef",
-                                          prefixedId opts ("fnref" ++ ref)] << 
-                                          sup << ref
+                        return $ sup <<
+                                 anchor ! [href ("#" ++ writerIdentifierPrefix opts ++ "fn" ++ ref),
+                                           theclass "footnoteRef",
+                                           prefixedId opts ("fnref" ++ ref)] << ref
     (Cite _ il)  -> inlineListToHtml opts il
 
 blockListToNote :: WriterOptions -> String -> [Block] -> State WriterState Html
diff --git a/tests/writer.html b/tests/writer.html
index c6f31b107..9ddf5c70c 100644
--- a/tests/writer.html
+++ b/tests/writer.html
@@ -1168,35 +1168,35 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+'<code>'+e+'</code>'+'<\/'+
 ><h1
   >Footnotes</h1
   ><p
-  >Here is a footnote reference,<a href="#fn1" class="footnoteRef" id="fnref1"
-    ><sup
-      >1</sup
-      ></a
-    > and another.<a href="#fn2" class="footnoteRef" id="fnref2"
-    ><sup
-      >2</sup
-      ></a
+  >Here is a footnote reference,<sup
+    ><a href="#fn1" class="footnoteRef" id="fnref1"
+      >1</a
+      ></sup
+    > and another.<sup
+    ><a href="#fn2" class="footnoteRef" id="fnref2"
+      >2</a
+      ></sup
     > This should <em
     >not</em
-    > be a footnote reference, because it contains a space.[^my note] Here is an inline note.<a href="#fn3" class="footnoteRef" id="fnref3"
-    ><sup
-      >3</sup
-      ></a
+    > be a footnote reference, because it contains a space.[^my note] Here is an inline note.<sup
+    ><a href="#fn3" class="footnoteRef" id="fnref3"
+      >3</a
+      ></sup
     ></p
   ><blockquote
   ><p
-    >Notes can go in quotes.<a href="#fn4" class="footnoteRef" id="fnref4"
-      ><sup
-	>4</sup
-	></a
+    >Notes can go in quotes.<sup
+      ><a href="#fn4" class="footnoteRef" id="fnref4"
+	>4</a
+	></sup
       ></p
     ></blockquote
   ><ol style="list-style-type: decimal;"
   ><li
-    >And in list items.<a href="#fn5" class="footnoteRef" id="fnref5"
-      ><sup
-	>5</sup
-	></a
+    >And in list items.<sup
+      ><a href="#fn5" class="footnoteRef" id="fnref5"
+	>5</a
+	></sup
       ></li
     ></ol
   ><p