Logo HTML Topics: Tag Order

Course Material Index  Section Index  Previous Page  Next Page

Nesting

It is important to realize that start and end tags will often be nested in the same way that brackets are nested, for example { ( [...] ) } where the inner [], middle (), and outer brackets {} are paired correctly. Using HTML style tags, one could write:

        <TAG1>
            <TAG2>
               <TAG3>
               ...
               </TAG3>
            </TAG2>
        </TAG1>
or alternatively:
        <TAG1>
            <TAG2>
            ...
            </TAG2>
            <TAG3>
            ...
            </TAG3>
        </TAG1>
but one should not interleave start and terminator tags:
        <TAG1>
            <TAG2>
            ...
            <TAG3>
            &</TAG2>
            ...
            </TAG3>
        </TAG1>
and also not interleave the order of the terminator tags:
        <TAG1>
            <TAG2>
               <TAG3>
               ...
        </TAG1>
               </TAG3>
            </TAG2>
The use of incorrectly nested tags will normally lead to unexpected (and possibly undesirable) behaviour by the browser (which may indeed depend on the actual browser used). Note that tags are not normally indented as shown here, though this approach can be useful in certain cases as a visual check that tags are paired correctly.


Course Material Index  Section Index  Previous Page  Next Page
© Copyright 1995-2006.  Birkbeck College, University of London.
 
Author(s): Jeremy Karl Cockcroft
Huub Driessen