Lecture Notes

HCI201 -- Lecture 3

Review/Discussion Questions

  1. List some common HTML tags.

    Ans:   <html>   <head>   <title>   <body>   <p>   <h1>   <strong>   <em>  

  2. What is meant by an empty tag in HTML?

    Ans: An empty tag is a start tag that does not take an end tag. In an empty tag, there is no content apart from that contained in the tag itself by the use of attributes.
    Examples:   <img src="logo.jpg" alt="Company logo">     <br>     <hr width="5px">

  3. In XHTML, every tag must have a corresponding end tag. So how should the three tags, given in the above examples, be written?

    Ans:  <img src="logo.jpg" alt="Company logo" />     <br />     <hr width="5px" />

  4. Write a span tag with an inline style that will change the word really in a sentence to red italic like this:

      This is really important.

    Ans: <span style="font-style:italic; color:red">

  5. What happens if you forget to include the matching end tag </span> for a <span> tag?

    Ans: The style defined in the span tag will continue until a </span> tag is encountered or to the end of the document.

  6. What does &nbsp; mean?

    Ans: Non-breaking space. The text on either side of the non-breaking space will not be split across two lines.

 

XHTML Rules

  1. Every tag requires a matching end tag.

  2. Tags must be nested. Do this:

      <head><title>My Web Page</title></head>

    not this:

      <head><title>My Web Page</head></title>

  3. Use combination start-end tag when there is nothing between the start and end tag (i.e., the tag is empty).
    Use <br /> instead of <br></br>. Using simply <br> is not legal in XHTML.

  4. Use <strong> and <em> instead of <b> and <i>.

  5. Optional (but recommended). Include a Doctype header at the beginning of an XHTML file, like:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

Inline CSS Styles

 

The Nonbreaking Space Symbol