Answers to Exercises, Chapter 10

These are answers to the exercises in the 3rd edition of Digital Multimedia (published February 2009) only. Do not try to use them in conjunction with the 2nd edition.

Test Questions

  1. An element is part of the document which forms a logical sub-division. A tag is a syntactical marker which signifies the start or end of an element. Thus <li>item</li> is an element, <li> and </li> are tags that show where it begins and ends and what its name is. Putting it another way, elements are sub-divisions of the document's structure, tags are the symbols that mark up the structure.
    • The closing </p> tag is missing from the end of the first paragraph. In XHTML, unlike HTML, elements must be explicitly closed.
    • The & character must always be encoded as a character entity reference and cannot be used as itself the way it is in XY&Z.
    • The em element begins inside the first paragraph and ends in the second, but elements in XHTML must be properly nested.
    • Attribute values must be enclosed in double quotes.
    • Not necessarily an error, but probably: If the quotes are inserted, the opening tag for the span would read <span class="product name">. This would put the span into the classes product and name, whereas it is probable that it was intended to belong to a single class, so the space should be omitted: <span class=productname>
    • The closing tag on the span element is malformed, it should be </span>.
    • There should be no space between the / and p in the final closing tag, which should just be </p>.
    It's instructive, but perhaps not as helpful as you might hope, to insert this snippet in an XHTML document with a proper DTD and so on and run it through the W3C XHTML validator service.
  2. You need to turn off the italicization as well as setting the font weight, otherwise you end up with boldface italics:
    em {
      font-weight: bold;
      font-style: normal;
    }
    			
  3. There are lots of ways to do this one. For example,
    body {
      line-height: 1.5em;
    }
    				
  4. Assume we have set the left margin of the body to a suitably large value:
    body {
      margin-left: 200px;
    }
    				
    The actual value doesn't matter and you can use relative units if you like, as long as it matches the negative margin width used in the rule for h1:
    h1 {
      font-weight: bold;
      font-size: 1.2em;
      float: left;
      margin-left: -200px;
      margin-top: 0;
    }
    			
    The font attributes are only illustrative. The margin-top has to be set to zero explicitly because most browsers' default style sheets put some space above level 1 headings.
  5. Trivially, a resource can be identified by different relative URLs, depending on where in the document hierarchy each URL appears. Domain names can be "forwarded" by various means so that pages on a site may be referred to by different URLs. For instance, http://www.macavon.co.uk and http://www.macavon.com will both take you to the same Web site. Finally, within a site different URLs can be made to refer to the same resource. This usually entails some server configuration or scripting.

    In contrast, at any instant, a given URL can only refer to a single resource, by definition. (But the resource may change over time.)

  6. HTML (including XHTML, of course) separates markup from appearance. In practical terms, this means that text can reflow according to the font size and window dimensions, and its physical position on the screen can be controlled by a style sheet, which may sometimes be disabled. What this means is that an arbitrary rectangular area cannot be uniquely and reliably associated with any particular part of the document's content. It is hard to see how links with no association to the content could be used meaningfully in hypertext. (Image maps could be considered a counter-example, but they are a special case, because they can only be defined within an image so they don't provide a mechanism for linking from arbitrary parts of a document.)
  7. Internet Explorer's implementation of object treats the ActiveX control as the embedded object, not the media object itself. The type attribute identifies the media type of the object, but the ActiveX control does not need to know this: each control only displays one type of object, so it is the identity of the ActiveX control that needs to be specified in order to ensure that it can deal with the object. This is done using the clsid attribute, as described in the text.

Discussion Topics: Hints and Tips

  1. The first part of Appendix A of Web Design: A Complete Introduction consists of a brief description of the capabilities of some programs for creating Web pages, which may serve as a starting point for this discussion.
  2. If you claim that this is practical, you will have to provide at least an outline of how it could be achieved. If you don't think it would be useful, can you say when, if ever, it would be useful to add links to definitions of terms occurring on a Web page?
  3. It isn't possible to provide a hint to this question without giving away the answer. The nohref attribute is not included in the current draft HTML5 specification. Does this make it impossible to achieve whatever it is you would use nohref to achieve?

Practical Tasks: Hints and Tips

  1. You should start by writing a rule with * as its selector to set all the font characteristics and spacing for every element to the same values, then write individual rules for each element that sets their colours. You'll probably want to add some rules for spacing and set the document width to a reasonable value.
  2. If you are experienced at scripting, you could try writing a script that performed this transformation, or some of it, automatically for you.
  3. This should be a simple task. You are only trying to demonstrate that the appearance and structure have been successfully separated, so in that sense it doesn't matter what you make the page look like, but it is always good practice to try to create something that looks good.
  4. As video is used more and more on the Web, finding good ways to incorporate clips into Web pages is becoming more important, but integrating time-based media into the framework of a static page remains a difficult task to achieve well.