Chapter 7: Moving Ahead with XHTML
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:
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:
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