Short inline annotations: title attribute.
<b>Customer</b>: Hello! I wish to register a complaint. Hello. Miss? <p> <b>Shopkeeper</b>: <span title="Colloquial pronunciation of 'What do you'" >Watcha</span> mean, miss? <p> <b>Customer</b>: Uh, I'm sorry, I have a cold. I wish to make a complaint. <p> <b>Shopkeeper</b>: Sorry, <span title="This is, of course, a lie.">we're closing for lunch</span>.Longer annotations: bidirectional linking via <a>:
<p> Announcer: Number 16: The <i>hand</i>. <p> Interviewer: Good evening. I have with me in the studio tonight Mr Norman St John Polevaulter, who for the past few years has been contradicting people. Mr Polevaulter, why <em>do</em> you contradict people? <p> Norman: I don't. <sup><a href="#fn1" id="r1">[1]</a></sup> <p> Interviewer: You told me you did! ... <section> <p id="fn1"><a href="#r1">[1]</a> This is, naturally, a lie, but paradoxically if it were true he could not say so without contradicting the interviewer and thus making it false.</p> </section>
li:target { background-color: #BFEFFF; }Thus, if the page URL ends with #explanation then the following list item would be highlighted:
<li id="explanation">It works like this: ...</li>
Terminology: An annotation is either a footnote or a reference (citation). The markers in the main text referring to those annotations are called annotation pointers.
Activating the library: The library consists of CSS to style annotations and pointers and of JavaScript that post-processes the HTML so that less code has to be written.
<link rel="stylesheet" href="footnotes.css" type="text/css"> <script src="footnotes.js"></script>Footnotes: The library processes the HTML so that footnote pointers are formatted as superscript and become links that, when clicked on, display the text of the footnote inline.
You can use an IIFE<a class="ptr">(1)</a> to avoid the global namespace<a class="ptr">(2)</a> being polluted. ... <h2>Footnotes</h2> <ol id="footnotes"> <li>IIFE is an acronym for Immediately-Invoked Function Expression.</li> <li>The global scope is reified as an object in JavaScript.</li> </ol>References: Reference pointers are processed and become links. The library also adds IDs to the reference list items. Due to the appropriate CSS, a list item will be highlighted and scrolled to if one clicks on a pointer.
JavaScript has many functional language constructs <a class="ptr">[1]</a>. For example: consult <a class="ptr">[2]</a> for an introduction to closures. ... <h2>References</h2> <ol id="references"> <li><a href="http://en.wikipedia.org/wiki/Functional_programming" ><i>Functional programming</i></a>. In <i>Wikipedia</i>. Retrieved 2011-12-03.</li> <li>Douglas Crockford, <i>JavaScript: The Good Parts</i>. O’Reilly. 2008-05-16.</li> </ol>