Web Page Design and Hosting

July 28, 2007

Chapter 7: Moving Ahead with XHTML

Filed under: Web Design — webmaster @ 7:26 am

Chapter 7: Moving Ahead with XHTML 155 Secret #111: Managing Nonempty Elements In XHTML, empty and nonempty elements are carried over from HTML. The difference is that they re treated in a more disciplined way. Nonempty elements, as you ll recall from the discussion in Chapter 6, are those elements that contain text content. These include such elements as headers, paragraphs, and list items. You ll also remember that some nonempty elements aren t required to have a closing tag in HTML. For example, list items can be written as follows:

  • List item one.
  • List item two.
  • List item three. Paragraphs are another prime example of a nonempty element for which, in HTML, the closing tag is considered optional. This is a perfectly valid practice in HTML. In XHTML, all nonempty elements must be closed. The corrected markup sample would then be as follows:
  • List item one.
  • List item two.
  • List item three.
  • tip I recommend making it a practice of closing nonempty elements in HTML too, even though it s not a requirement. If you ever choose to upgrade those files to XHTML, it ll be much easier. Also, it can improve CSS rendering in some browsers. Secret #112: Terminating Empty Elements All empty elements must be terminated. Empty elements are those elements without text content, and they are always represented by a single tag. In XML, empty elements are terminated with a trailing slash:

    XHTML adopts this practice so empty elements can terminate the same way, as in the following:

    You might have noticed that a space appears before the trailing slash in most XHTML documents. This really emerged as a browser hack for older browsers that couldn t properly interpret the slash if it came immediately after a character. Since the specifications allow the white space, most XHTML authors and authoring tools use the space to avoid browsers misinterpreting empty elements:

    Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

    No Comments

    No comments yet.

    RSS feed for comments on this post. TrackBack URI

    Sorry, the comment form is closed at this time.

    Powered by Java Web Hosting