ref: a8083462e62459b2ae8a243dc4ba88416eba03b1
dir: /lib/ebooks/understandingoeb/chapter4.html/
<?xml version='1.0'?> <!DOCTYPE html PUBLIC "+//ISBN 0-9673008-1-9//DTD OEB 1.0.1 Document//EN" "http://openebook.org/dtds/oeb-1.0.1/oebdoc101.dtd"> <?xml-stylesheet href="understandingoeb.css" type="text/x-oeb1-css"?> <html> <head> <link rel="stylesheet" type="text/x-oeb1-css" href="understandingoeb.css" /> <title>Understanding OEB Chapter 4</title> <meta name="author" content="Garret Wilson" /> <meta name="copyright" content="Copyright (c) 2000-2001 Garret Wilson. All rights reserved." /> </head> <body> <h2 id="chapter4">4. Essential OEB Elements</h2> <p>You now know the minimum structural requirements of creating a publication in OEB format. You're beginning to understand some of the reasoning behind latest directions of information storage formats such as XML, which OEB is based on. Right now, you could place almost any work in a few OEB documents and an OEB package, and it would at least be legal OEB and work with a compliant OEB reading system. You also know how to create style sheets and associate them with your documents.</p> <p>What you've learned so far will work fine for your one-paragraph masterpiece. But once you try to use OEB to create a slightly longer sequel, you'll probably very soon run into some very real needs: "How do I display lists?" "How do I change the font?" "How so I create links from one section of my book to another?" The OEB Publication Structure has some very real answers to these questions. Even better yet, since OEB is built upon XML, the following chapters will show you how to create your own answers in areas that OEB does not yet address.</p> <p>You've had a glance at a few elements defined by OEB, such as <code><p></code>, <code><em></code> and <code><dfn></code>. OEB has a substantial number of other tags already defined for you to use; obviously, you'll need to know at least some of the others to do anything useful with OEB. We'll now look at essential elements and styles that you'll need in day-to-day use of OEB. If you've already started putting together an OEB publication, hopefully we'll answer some of the issues you've already encountered. Otherwise, we'll get a lot of common questions out of the way and prepare you for the real-world OEB creation project found in the next chapter.</p> <p>It's important to note that the OEB elements discussed here are a basic set of elements defined by OEB. OEB is flexible enough to allow extended documents that include user-defined elements, and this process is likely to be enhanced even more in future OEB versions. Creating user-defined elements is beyond the scope of this current edition, but will likely be addressed in an upcoming version of this book.</p> <h3 id="inlineelements">Inline Elements</h3> <p>Although XML allows any number of elements to be defined, OEB has defined a certain set of elements to be used in documents. You've seen and used a few of those, such as <code><p></code>, <code><em></code> and <code><dfn></code>. Besides defining which tags can be used, OEB also specifies the location and contexts in which these elements can appear. You've probably understood intuitively, for example, that emphasized text goes inside a paragraph, like this:</p> <blockquote><code><p></code>This is <code><em></code>emphasized<code></em></code> text.<code></p></code></blockquote> <p>You probably didn't even consider putting a paragraph inside of emphasized text:</p> <blockquote><strong>Illegal!</strong> <code><p></code>This is <code><em></code>emphasized text with a <code><p></code>paragraph<code></p></code> inside<code></em></code> the emphasized text.<code></p></code></blockquote> <p>As you might have guessed, this sort of construction is not allowed. The elements <code><em></code> and <code><dfn></code> can only appear inside paragraphs (and lists and other similar elements), and are therefore considered <em>inline</em> elements. Those are the elements we'll examine here.</p> <div class="sidebar" id="xmlcontentmodels"> <h4 class="sidebarTitle">More Information: XML Content Models</h4> <p>XML could be considered a general markup language that acts as a toolkit for creating other markup languages. OEB uses XML to create its own markup language called the OEB Publication Structure. OEB uses XML not only to create a set of elements to be used (the <dfn>tag set</dfn>), but also to specify where the elements may appear. The specification of the correct locations of elements is called a <dfn>content model</dfn>.</p> <p>HTML uses a very lenient content model; a web browser will read HTML files that have elements that appear just about anywhere. This is not only notoriously hard to process, it also results in many ambiguities in what was actually meant by the author of the document. Since we'd like to follow the trend in encoding data and meaning into documents, this ambiguity is not acceptable.</p> <p>The content model used by OEB is therefore more strict than traditional HTML, and closely follows <a href="http://www.w3.org/TR/xhtml1/">XHTML</a>, a new version of HTML created specifically to be used with XML. This means that some constructs which could be used in HTML are not allowed in OEB. For example, the inline element <code><em></code> could be used in HTML to make several paragraphs emphasized:</p> <blockquote><strong>Legal HTML, Illegal OEB:</strong><br /> <code><em></code><br /> <code><p></code>Paragraph 1<code></p></code><br /> <code><p></code>Paragraph 2<code></p></code><br /> <code></em></code> </blockquote> <p>Since <code><em></code> is an inline element, this will not work in an OEB document. Fixing this problem is simple, however: just bring the <code><em></code> back inside each <code><p></code> element:</p> <blockquote><strong>Legal HTML, Legal OEB:</strong><br /> <code><p><em></code>Paragraph 1<code></em></p></code><br /> <code><p><em></code>Paragraph 2<code></em></p></code><br /> </blockquote> <p>The actual OEB content model is not discussed explitely in the OEB specification, but it is defined in the OEB XML Document Type Declaration (DTD), which will be discussed later. Many times, such as in the case of the <code><em></code> element, the you can probably tell intuitively where an element can appear. In all cases, OEB validation software will be able to check your document against the OEB DTD and tell you whether or not your document has all its elements in the correct places.</p> </div> <h4 id="emelement">The <code><em></code> Element</h4> <p>You've already seen the <code><em></code> element — perhaps more than you've wanted. It bears repeating that the <code><em></code> element should be used instead of the <code><i></code> (italics) element in most cases, designating that the text should be emphasized but not specifying how the emphasized text should appear. An example of how specific text could be emphasized might be this:</p> <blockquote><code><p></code>Although the venture capital company seemed <code><em></code>really<code></em></code> interested in our project, perhaps the representative only <code><em></code>seemed<code></em></code> really interested.<code></p></code></blockquote> <blockquote>Although the venture capital company seemed <span style="font-style: italic">really</span> interested in our project, perhaps the representative only <span style="font-style: italic">seemed</span> really interested.</blockquote> <h4 id="strongelement">The <code><strong></code> Element</h4> <p>The <code><strong></code> element is similarly to the <code><em></code> in that it specifies that a section of text should be emphasized, but is used in most cases where bold text would be used. In fact, the default rendering of the <code><strong></code> element is using a bold font, although we've seen that any default rendering can be changed using styles.</p> <p>Also similar to the <code><em></code> tag, OEB has a carryover tag from HTML that functions similar to the <code><strong></code> tag but that specifies actual formatting: the <code><b></code> tag, representing bold text. For reasons we've explained earlier, we don't recommend using tags that specify presentation information within a document itself. Therefore, you should in most cases use <code><strong></code> rather than <code><b></code> whenever marking up text usually rendered in bold.</p> <blockquote><code><p></code>The Hindi letter "ka" is pronounced similarly to the first part of the English word, "<code><strong></code>cu<code></strong></code>p".<code></p></code></blockquote> <blockquote>The Hindi letter "ka" is pronounced similarly to the first part of the English word, "<span style="font-weight: bolder">cu</span>p".<code></p></code></blockquote> <h4 id="dfnelement">The <code><dfn></code> Element</h4> <p>We've already discussed using the <code><dfn></code> element to represent a word or words that are being defined for the first time.</p> <blockquote><code><p></code>The Hindi alphabet is usually specified as being a <code><dfn></code>syllabary<code></dfn></code>, since each letter of a word represents a syllable.<code></p></code></blockquote> <blockquote>The Hindi alphabet is usually specified as being a <dfn>syllabary</dfn>, since each letter of a word represents a syllable.</blockquote> <h4 id="codeelement">The <code><code></code> Element</h4> <p>OEB has several inline elements, some of which you'll use and some of which you'll never need unless creating certain esoteric documents. We mention that <code><code></code> element here because, since OEB was created by the computer-using community, it's likely that the first applications of OEB (this work included) will refer to computer programs or software.</p> <p>The <code><code></code> element was created to represent a section of computer program code, or data that should be entered by the user. This element is usually rendered in a monospaced font such as Courier, but as we've repeatedly stressed, you can change this behavior using styles.</p> <blockquote><code><p></code>In many programming languages, the statement <code><code></code>variable=16<code></code></code> represents an assignment operation, assigning the value on the right to the variable on the left of the equals sign.<code></p></code></blockquote> <blockquote>In many programming languages, the statement <code>variable=16</code> represents an assignment operation, assigning the value on the right to the variable on the left of the equals sign.</blockquote> <h4 id="citeelement">The <code><cite></code> Element</h4> <p>Many nonfiction works include information from other sources, and when they do so it is proper to cite the source from which the material was derived. The <code><cite></code> provides a standard way to indicate a cited source.</p> <blockquote> <code><p></code>"The UN, like the League of Nations before it, was designed around the concept of state sovereignty" (<code><cite></code>Calvocoressi 1996<code></cite></code>). </blockquote> <blockquote> "The UN, like the League of Nations before it, was designed around the concept of state sovereignty" (<cite>Calvocoressi 1996</cite>). </blockquote> <h4 id="spanelement">The <code><span></code> Element</h4> <p>Our discussion of inline elements has thus far assumed that, if you looked hard enough, you could find an OEB element that represented more or less the meaning of the section of text to which you're referring. We've stressed that you can always later change the style of the particular element you chose.</p> <p>What if you can't find an element that's appropriate, but still want to specify a style for a section of text? OEB provides (again borrowed from HTML) a generic element, <code><span></code>, that has no meaning other than to specify a section of text. The <code><span></code> element has the normal <code>style</code> and <code>class</code> attributes, allowing you to specify style for an arbitrary section of text. For example, imagine you want to somehow highlight the vowels in an alphabet, but don't want to use <code><em></code> because you'd like to use some separate style. You could always create a specific style class for <code><em></code>, but you might rather specify style information from scratch using <code><span></code>, like this:</p> <blockquote><code><p></code>English Alphabet: <code><span style="color: red"></code>A<code></span></code> B C D <code><span style="color: red"></code>E<code></span></code> F G...<code></p></code></blockquote> <blockquote>English Alphabet: <span style="color: red">A</span> B C D <span style="color: red">E</span> F G...</blockquote> <p>You should immediately protest that actual style information should not be included in the document itself. A slight modification resolves this problem and makes the use of <code><span></code> acceptable. First specify a style class, such as <code>.vowel {color:red}</code>, and then use this class in the <code><span></code> element:</p> <blockquote><strong>Style Sheet:</strong> <code>.vowel {color:red}</code></blockquote> <blockquote><strong>Document:</strong> <code><p></code>English Alphabet: <code><span class="vowel"></code>A<code></span></code> B C D <code><span class="vowel"></code>E<code></span></code> F G...<code></p></code></blockquote> <blockquote>English Alphabet: <span style="color: red">A</span> B C D <span style="color: red">E</span> F G...</blockquote> <div class="sidebar" id="customelements"> <h4 class="sidebarTitle">More Information: Creating Custom Elements</h4> <p>Using the <code><span></code> element in the way we've just outlined is remarkably close to creating a new element named <code><vowel></code>; instead, we've used the <code><span></code> element with a style class named "vowel", which ends of serving the same function.</p> <p>The <code><span></code> element was introduced in HTML before XML was available, and is therefore the only way standard HTML can add what may be called pseudo-elements into an HTML document. XML, on the other hand, includes a method (which will be discussed later) for creating real custom elements from scratch. Since OEB is based on XML, it does allow one to create something called an <dfn>extended</dfn> OEB document which includes custom-built tags, meaning that the <code><span></code> element is little more than an a clumsy, inefficient way to do something that is much more elegantly done using standard XML techniques.</p> <p>Why then does OEB include the <code><span></code> element? One of the reasons should be quite familiar by now: since this tag is included in HTML, it was brought over into OEB so that standard HTML pages could be converted to OEB with minimal modification. The creation of custom elements using XML is furthermore more difficult than using the <code><span></code> element. Another reason should also be familiar: custom XML elements do not display correctly on HTML browsers.</p> <p>The majority of the OEB Authoring Group therefore felt it a higher priority to quickly release a specification that would bring about consensus in a quickly growing eBook industry than to force the adoption of barely released technologies such as custom XML elements. Happily, the OEBPS 1.0.1 still allows those who wish to follow useful standardization trends can still use XML to create custom elements. A discussion of how this is done is outside the scope of the current release of this book.</p> </div> <h4 id="brelement">The <code><br></code> Element</h4> <p>You learned in an earlier chapter that multiple adjacent whitespace characters, such as spaces and line breaks, are always replaced with a single space character before the text is displayed. This seems reasonable until you encounters a situation in which you'd like to display text on a separate line, perhaps like this:</p> <blockquote> <code><p></code>...Karl had three siblings:<br /> Kris<br /> Krista<br /> Karla<code></p></code> </blockquote> <p>As you'll soon realize, if you've forgotten our earlier discussion about whitespace, what is displayed is not exactly what was entered:</p> <blockquote>...Karl had three siblings: Kris Krista Karla</blockquote> <p>You could always put the name of each of Karl's siblings in a separate paragraph, but they aren't really separate paragraphs. Besides, you don't want to risk their being formatted like paragraphs when displayed (either indented or separated by blank lines, depending on the reading system).</p> <p>The real solution here is to use a separate list element, which you'll learn about later in this chapter. But you might insist that these items should go <em>inside</em> the paragraph, and you want to choose where the line breaks appear. A better example might be a poem, in which you'd like to guarantee that a line break appears after each line:</p> <blockquote> <code><p></code>There was a young creature named Karl<br /> Whose siblings would say with a snarl<br /> We'll share what we eat:<br /> Just some bones from the meat<br /> And a little of "ic" from the "garl".<code></p></code> </blockquote> <p>Here again, it would be more preferable if there were a <code><poem></code> element in OEB. There isn't. Short of creating your own tag for this situation, OEB provides an element that specifies that a line break should appear: the <code><br></code> element.</p> <p>The <code><br></code> element is different than the elements examined so far in that it cannot have content; since it signifies a line break at a particular location in the text, it doesn't display text and has no need to hold text. The <code><br></code> element is therefore referred to as an <dfn>empty element</dfn>. You might expect the <code><br></code> element to simply have a beginning and ending tag with nothing in between (<code><br></code><code></br></code>). However, XML specifies a special format for empty elements by combining the beginning and ending tags into one tag: <code><br /></code></p> <ul> <li id="emptyElement"><strong>XML Rule 6:</strong> (<em>Empty Elements</em>) An element that cannot have text between its beginning and ending tags is classified as a <dfn>empty element</dfn>, and has a special form of a single tag with the element name followed by a slash (/): <code><name /></code></li> </ul> <p><strong>Important:</strong> While not required by XML, OEB specifies that all empty tags must have a space between the tag name and the slash character. This is to ensure that OEB documents can be displayed more or less correctly in HTML browsers.</p> <p>The <code><br></code> element might therefore be used in a re-write of Lewis Carroll's <i>Alice's Adventures in Wonderland</i>:</p> <blockquote> <code><p></code>Alice fell down the rabbit hole...<code><br /></code><br /> Down...<code><br /></code><br /> Down...<code><br /></code><br /> Down...<code></p></code> </blockquote> <p>This would be correctly displayed as expected:</p> <blockquote> Alice fell down the rabbit hole...<br /> Down...<br /> Down...<br /> Down... </blockquote> <p>The <code><br></code> element, however, has the potential of being abused and overused. In most places, items might more appropriately be placed in separate paragraphs, or perhaps in a list. In keeping with our goal of using markup to encode meaning into a document, it would probably be better to place a poem inside a <code><poem></code> element or something similar, although in this case we would have to define such an element before it could be used. The use of <code><br></code> to show the plight of Alice, above, is certainly the easiest and perhaps even an appropriate way to create the desired visual effect. We'd just like to encourage you to make sure that the <code><br></code> element is appropriate for the situation before using it.</p> <h4 id="aelement">The <code><a></code> Element</h4> <p>The anchor element, <code><a></code>, was first made popular by HTML. Since the <code><a></code> element is responsible for linking documents and sections of documents, this element is responsible for the "hypertext" part of HTML. Without <code><a></code>, HTML might otherwise have only been "TML", a text markup language with no linking capabilities. The OEB Publication Structure incorporated <code><a></code> into its tag set with hardly any modifications to its fundamental form.</p> <p>With its linking capabilites, <code><a></code> is the first tag we've discussed that starts to allow static pages in a book to come to life, to allow interaction with the user. The Open eBook specification begins with the assumption that a user will be provided with a paging function that will allow traversal through the contents of a book. The most fundamental purpose for hypertext anchors might be to link to reference sections or a glossary; however, the <code><a></code> element allows the author to provide many more complex navigation capabilites, allowing readers to even choose an arbitrary path through the book as they read.</p> <p>The most important attribute of the <code><a></code> element is <code>href</code>. As you've seen in elements both in the OEB package and in OEB style sheets, the <code>href</code> attribute specifies a "hypertext reference" location. Usually, the value of this attribute refers to a file; in other instances is can refer to a specific location within a file.</p> <p>Let's revisit a section from the first work we created.</p> <blockquote> <code><p></code>Years ago, when strange creatures ruled the earth, the seas were beginning to form, and humans had yet to appear, there lived a young blovjus named Karl.<code></p></code> </blockquote> <p>Now, some uninformed readers may not know what a "blovjus" is. You may wish to provide a definition a reader can read. Having a definition in the text is unacceptable; you don't want to bother your many readers who know exactly what a blovjus is and do not want to be told again. Instead, you elect to place the definition in a separate OEB document file named <code>blovjus.html</code>:</p> <blockquote> <code><?xml version='1.0'?></code><br /> <code><!DOCTYPE html PUBLIC "+//ISBN 0-9673008-1-9//DTD OEB 1.0.1 Document//EN" "http://openebook.org/dtds/oeb-1.0.1/oebdoc101.dtd"></code><br /> <code><html></code><br /> <code><body></code><br /> <code><p><strong></code>blovjus<code></strong></code> A strange, mythical creature which lived many years ago; sometimes it stole supper from its siblings.<code></p></code><br /> <code></body></code><br /> <code></html></code> </blockquote> <p>Using the <code><a></code> tag, it's a simple job to link "blovjus" in the text to its definition:</p> <blockquote> <code><p></code>Years ago, when strange creatures ruled the earth, the seas were beginning to form, and humans had yet to appear, there lived a young <code><a href="blovjus.html"></code>blovjus<code></a></code> named Karl.<code></p></code> </blockquote> <p>Anchor elements can also be used to mark, or <dfn>anchor</dfn>, a section of text in a document (although this function is less important since each element in OEB contains an <code>id</code> attribute). This way, two <code><a></code> elements can be used together, one to mark a location and another to link to that location. This allows links not only to files, but to a specific location in a file. The tag serving as an anchor will use the <code>id</code> tag to provide a name for the anchor. The tag serving as a link will use the <code>href</code> as before to refer to a file, except that a pound sign (#) will be appended followed by the id of the anchor which serves as the link <dfn>target</dfn>.</p> <p>This is actually quite simple in practice. Assume that you have so many uninformed readers that you've created an entire glossary with many definitions. This glossary replaces the <code>blovjus.html</code> document file you created earlier, containing "blovjus" and other terms:</p> <blockquote> <code><?xml version='1.0'?></code><br /> <code><!DOCTYPE html PUBLIC "+//ISBN 0-9673008-1-9//DTD OEB 1.0.1 Document//EN" "http://openebook.org/dtds/oeb-1.0.1/oebdoc101.dtd"></code><br /> <code><html></code><br /> <code><body></code><br /> <code><p><a id="blovjus"><strong></code>blovjus<code></strong></a></code> A strange, mythical creature which lived many years ago; sometimes it stole supper from its siblings.<code></p></code><br /> <code><p><a id="earth"><strong></code>earth<code></strong></a></code> The third planet from the sun.<code></p></code><br /> <code></body></code><br /> <code></html></code> </blockquote> <p>Note that we've placed an <code><a></code> element around each term to serve as an anchor to mark the link targer. We've specified a name for each target using the <code>id</code> attribute. Here, we've used names that match the terms we're defining, but we could have used any names as long as they are unique and we use the same names in the links. Here's what the links look like in our original file:</p> <blockquote> <code><p></code>Years ago, when strange creatures ruled the <code><a href="glossary.html#earth"></code>earth<code></a></code>, the seas were beginning to form, and humans had yet to appear, there lived a young <code><a href="glossary.html#blovjus"></code>blovjus<code></a></code> named Karl.<code></p></code> </blockquote> <p>In each link, we specify the document in which the definitions reside (<code>glossary.html</code> in this example), followed by a pound sign (#) and then the ID of the appropriate definition (here, <code>earth</code> and <code>blovjus</code>). It is here that we must always make sure the name in the <code>href</code> attribute always matches the name in the target anchor tag's <code>id</code> attribute.</p> <p>This application of the anchor tag as a true anchor is less useful since OEB provides an <code>id</code> attribute for most elements. Instead of adding an <code><a></code> element and <code>id</code> attribute to serve as an anchor, you can instead add an <code>id</code> to the element to which you want to link. The above example, then, would appear like this:</p> <blockquote> <code><?xml version='1.0'?></code><br /> <code><!DOCTYPE html PUBLIC "+//ISBN 0-9673008-1-9//DTD OEB 1.0.1 Document//EN" "http://openebook.org/dtds/oeb-1.0.1/oebdoc101.dtd"></code><br /> <code><html></code><br /> <code><body></code><br /> <code><p id="blovjus"><strong></code>blovjus<code></strong></code> A strange, mythical creature which lived many years ago; sometimes it stole supper from its siblings.<code></p></code><br /> <code><p id="earth"><strong></code>earth<code></strong></code> The third planet from the sun.<code></p></code><br /> <code></body></code><br /> <code></html></code> </blockquote> <p>This version of specifying a link target is the recommended one — there is no need to specify an anchor for the target because almost any OEB element can contain an ID attribute. The <code><a></code> element will still be needed, of course, to link <em>to</em> the referenced location.</p> <p>Anchor tags are the first step in leveraging the capabilities of electronic books which static books do not have. Hypertext linking has many uses, from creating tables of contents to providing user-initiated changes in a plot. We'll address some of these uses in the following chapters.</p> <h3 id="blockelements">Block Elements</h3> <p>Block elements could be considered the opposite of inline elements. They are the enclosing elements within which inline elements are placed. That is, inline elements have to have some element to be inside; this element is ultimately a block element (although inline elements can appear inside other inline elements). You've already seen one example of a block element, the <code><p></code> element representing a paragraph. Block elements could also be classified as elements that automatically have a line break before and after them; they might therefore also be appropriately called "out-of-line" elements.</p> <p>Traditionally, block elements in HTML also had a blank line immediately before and immediately after them, but OEB reading systems may prefer to display block elements differently, indenting the first line of text in a <code><p></code> element, for example.</p> <h4 id="pelement">The <code><p></code> Element</h4> <p>The <code><p></code> element is probably the most straightforward block-level element, and probably the most common. Every paragraph in OEB should be surrounded by <code><p></code>...<code></p></code>. As we've certainly used plenty of paragraphs up to this point, we won't give any examples here. Instead, we'll just give one precaution: be careful not to <em> overuse</em> the <code><p></code> tag. Make sure the block of text you're marking up is really a paragraph and not, say, a list or a heading, both of which are covered in the sections below.</p> <h4 id="headingelements">The <code><h1></code>...<code><h6></code> Heading Elements</h4> <p>Perhaps the second most common block element is actually a group of similar elements: <code><h1></code>, <code><h2></code>, <code><h3></code>, <code><h4></code>, <code><h5></code>, and <code><h6></code>. These elements represent different levels of headings in your document.</p> <p>What does "heading" mean? It represents whatever you want it to represent. You could use <code><h1></code> to represent the title of your book on the title page, and use <code><h2></code> to represent the title of each chapter. Alternatively, you could use <code><h1></code> to represent each chapter title, <code><h2></code> to represent each chapter subtitle, and use a completely separate style class (or custom XML element) to represent the book title on the title page.</p> <p>All this is at your discretion because the heading elements do not directly correspond to any particular division of a book; they do not have a particular meaning, such as "chapter title" or "subtitle". The only thing that you can be sure of is that the default rendering method for each higher-numbered heading (such as <code><h1></code>) will be larger than a lower-numbered heading (such as <code><h2></code>).</p> <p>The lack of a particular meaning for the <code><hX></code> elements makes them slightly less useful than one might expect. Some early eBook reading systems assigned meanings to the <code><hX></code> elements, allowing the reading system to automatically find and understand when chapters begin, for example. Other markup languages have specific tags that represent chapters and other divisions. OEBPS 1.0, however, has no elements that specifically indicate book structure, so you'll have to make do with the heading elements. While OEB may introduce such elements in the future, for now using the heading elements is highly preferable to specifying the styles of headings manually, of course. Just remember that the meanings assigned to the heading elements are completely up to you. You might choose, for example, to use them like this:</p> <blockquote> <code><h1></code>Karl the Creature<code></h1></code><br /> <code><h2></code>Chapter 1: Karl as a Kid<code></h2></code><br /> <code><p></code>Years ago...<code></p></code><br /> </blockquote> <blockquote> <h1>Karl the Creature</h1> <h2>Episode 1: Karl as a Kid</h2> <p>Years ago...</p> </blockquote> <h4 id="lists">Lists, Ordered (<code><ol></code>) and Unordered (<code><ul></code>)</h4> <p>Almost every work, especially non-fiction educational works (like this one), have instances in which a list of items must be displayed. Many times the items in these lists are shown in a particular order, each item with a particular number. These lists are called <dfn>ordered lists</dfn>:</p> <blockquote> The names of the first three planets from the sun, in order, are:<br /> 1. Mercury<br /> 2. Venus<br /> 3. Earth </blockquote> <p>Not only must the numbers of each item in the list be carefully considered, care must be taken to ensure that the list is formatted correctly. Whenever the list is modified or reordered, care must be taken in modifying the numbering involved. Furthermore, there's no indication encoded in the file that this is a list; no meaning has been added to text that a computer or data-retrieval program could extract.</p> <p>OEB provides elements that solves all of these problems. In this case, we can use markup to specify that we have an ordered list (using the <code><ul></code> element), and that each item in the list is (as you would expect) a list item (using the <code><li></code> element). Ordered lists in OEB therefore consist of two separate elements, <code><ol></code> and <code><li></code>, used in conjunction like this:</p> <blockquote> <code><p></code>The names of the first three planets from the sun, in order, are:<code></p></code><br /> <code><ol></code><br /> <code><li></code>Mercury<code></li></code><br /> <code><li></code>Venus<code></li></code><br /> <code><li></code>Earth<code></li></code><br /> <code></ol></code> </blockquote> <blockquote> <p>The names of the first three planets from the sun, in order, are:</p> <ol> <li>Mercury</li> <li>Venus</li> <li>Earth</li> </ol> </blockquote> <p>Notice two things: first, the number of each list item does not need to be specified; it is supplied automatically when the list is displayed. Second, the introductory statement, "The names of the first three planets...", is not technically part of the list, so it is not placed within the <code><ol></code>...<code></ol></code> tags. The OEB publication structure allows you to specify the formatting, the type, and even a language-specific representation of the numbers used in a list.</p> <p>Some types of lists do not have numbers associated with them; they are <dfn>unordered lists</dfn>. If you're listing items in a grocery list, for example, you may not care about the order in which they are purchased. You would therefore use the <code><ul></code> for the unordered list, which functions exactly like the <code><ol></code> element used for ordered lists:</p> <blockquote> <code><p></code>Please purchase the following items:<code></p></code><br /> <code><ul></code><br /> <code><li></code>Bread<code></li></code><br /> <code><li></code>Eggs<code></li></code><br /> <code><li></code>Milk<code></li></code><br /> <code></ul></code> </blockquote> <blockquote> <p>Please purchase the following items:</p> <ul> <li>Bread</li> <li>Eggs</li> <li>Milk</li> </ul> </blockquote> <p>The default rendering method for unordered lists is to display a small round circle next to each item. You'll learn later how to use styles to modify this behavior. Most importantly, we've specified that the information is actually a list of items, and we can later, if we wish, arbitrarily change the way this list is displayed using styles, without changing the actual text of the document.</p> <h4 id="divelement">The <code><div></code> Element</h4> <p>The <code><span></code> element, as you saw earlier, provided a convenient way to specify style information about an arbitrary set of characters inside a block element. That last aspect somewhat limits its applicability, though: since <code><span></code> is an inline element, it can't be used to specify style information for more than one block element. That's why <code><div></code> in included in OEB.</p> <p>The <code><div></code> element is the block-level equivalent to the inline <code><span></code> span. It has no meaning in itself; its sole purpose is to group several block-level elements for the purpose of applying styles, for example. To see an example of where the <code><div></code> element could be applied, let's revisit an example of an inappropriate use of the <code><em></code> element:</p> <blockquote><strong>Illegal:</strong><br /> <code><em></code><br /> <code><p></code>Paragraph 1<code></p></code><br /> <code><p></code>Paragraph 2<code></p></code><br /> <code></em></code> </blockquote> <p>As we noted when discussing the OEB content model, the <code><em></code> element, being an inline element, cannot enclose the <code><p></code> element, a block element. We explained that the <code><em></code> element could simply be moved inside the <code><p></code>, like this:</p> <blockquote><strong>Legal OEB:</strong><br /> <code><p><em></code>Paragraph 1<code></em></p></code><br /> <code><p><em></code>Paragraph 2<code></em></p></code><br /> </blockquote> <p>The same effect could be achieved using the <code><div></code> element in a similar manner to that used in the first example. An emphasis style class could be created and applied to a surrounding <code><div></code> element:</p> <blockquote><strong>Style Sheet:</strong> <code>.emphasis {font-style: italic}</code></blockquote> <blockquote><strong>Document:</strong><br /> <code><div class="emphasis"></code><br /> <code><p></code>Paragraph 1<code></p></code><br /> <code><p></code>Paragraph 2<code></p></code><br /> <code></div></code> </blockquote> <p>As with the <code><span></code> element, the <code><div></code> element is another carryover from HTML that allows one to simulate the creation of a custom tag. Also similarly to how the <code><span></code> element is used, XML allows true custom elements to be created, making <code><div></code>, although convenient, somewhat redundant. It's this convenience that makes <code><div></code> quite attractive and perhaps acceptable in some situations. Before using it, however, make sure that a custom XML element wouldn't be more appropriate.</p> <h4 id="centerelement">The <code><center></code> Element (deprecated)</h4> <p>OEB includes <code><center></code> but marks it as <dfn>deprecated</dfn>: its use is allowed so that HTML documents will not require much modification, but its use is discouraged. In fact, the <code><center></code> element is mentioned here only because its use has become <em>very</em> popular over the years in HTML documents. We echo the exhortation of the OEBPS specification (and the latest version of HTML) that the <code><center></code> element should not be used in new OEB document; explicitly specifying that a section of text should be centered goes against the concept of separation of content and presentation.</p> <blockquote> <strong>Deprecated:</strong> <code><center></code>Chapter 1: Karl as a Kid<code></center></code> </blockquote> <blockquote> <div style="text-align: center">Chapter 1: Karl as a Kid</div> </blockquote> <p>As an alternative, OEB (and HTML) allow text to be centered using styles. Specifically, the <code>text-align</code> property, which we'll discuss later in this chapter, allows a <code>"center"</code> value that gives the desired effect. Using style classes with the <code><div></code> element we just discussed might yield something like this:</p> <blockquote><strong>Style Sheet:</strong> <code>.chapterhead {text-align: center}</code></blockquote> <blockquote><strong>Document:</strong> <code><div class="chapterhead"></code>Chapter 1: Karl as a Kid<code></div></code> </blockquote> <p>As is usually the case with <code><div></code>, there are better ways to specify which text should be centered. If you're already using <code><h1></code> for chapter headings, for example, specifying that the chapter headings should be centered is quite easy using styles, and illustrates how convenient and appropriate style sheets can be:</p> <blockquote><strong>Style Sheet:</strong> <code>h1 {text-align: center}</code></blockquote> <blockquote><strong>Document:</strong> <code><h1></code>Chapter 1: Karl as a Kid<code></h1></code> </blockquote> <p>Whatever method you choose to use to center text, we encourage you that it not be the <code><center></code> element.</p> <h4 id="blockquoteelement">The <code><blockquote></code> Element</h4> <p>In contrast to the <code><center></code> element, <code><blockquote></code> is a good example of how elements should encode meaning into a document and assist in separating content from presentation. Many nonfiction works have sentences quoted from other works. If a quote is several sentences or even several paragraphs long, it is usually placed in a separate, indented paragraph or group of paragraphs. The <code><blockquote></code> element allows text to be specified as a block of quoted text without worrying how it will be formatted. Usually, the default indented style is acceptable, but this can easily be changed using styles.</p> <p>The <code><blockquote></code> element has one optional attribute, <code>cite</code>, which allows the web address location of the quote to be specified. Note that the inline element with the same name as the attribute, <code><cite></code>, is often used in conjunction with the <code><blockquote></code> element:</p> <blockquote> <code><blockquote cite="http://www.un.org/Overview/rights.html"></code><br /> Everyone is entitled to all the rights and freedoms set forth in this Declaration, without distinction of any kind, such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. Furthermore, no distinction shall be made on the basis of the political, jurisdictional or international status of the country or territory to which a person belongs, whether it be independent, trust, non-self-governing or under any other limitation of sovereignty. (<code><cite></code>UN Declaration of Universal Human Rights, Article 2, December 10, 1948<code></cite></code>)<br /> <code></blockquote></code> </blockquote> <blockquote cite="http://www.un.org/Overview/rights.html"> Everyone is entitled to all the rights and freedoms set forth in this Declaration, without distinction of any kind, such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. Furthermore, no distinction shall be made on the basis of the political, jurisdictional or international status of the country or territory to which a person belongs, whether it be independent, trust, non-self-governing or under any other limitation of sovereignty. (<cite>UN Declaration of Universal Human Rights, Article 2, December 10, 1948</cite>) </blockquote> </body> </html>