Monday, March 23, 2009

HTML Confusion

Hmm. Interesting. The following HTML does not behave as I would expect it to in all of the major browsers:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>This is a test</title>
    </head>
    <body>
        <div>
            <a href=""/>This should not be a link.  
            <b />This should not be Bold.  
            <i />This should not be Italic. 
            <u />This should not be Underlined.
            <div style="background: red;" />This should not be Red. 
        <div>
    </body>
</html>

In xml, a tag with the form <x /> would be an empty xml element. So the rendering of the above ends up being quite confusing as each of those tags ends up being opening tags without closing tags.

Perhaps this is some remnant of the pre-xml days when html was still being defined.

No comments: