html tag and XHTML

When reworking my portfolio site (still working on it) I made the pages XHTML 1.1 compliant and output them as application/xhtml+xml. There is however a problem with these pages are opened in browsers that support the output as XML (others see it as html due to the content negotiation). The html tag that used to be ignored for display purposes, is now displayed too and is in fact a container itself (just like a div).

Once you give the body tag a background color with CSS, you start to notice that there is something more than just the body tag.

Portfolio without html tag styled
html tag without style

The background of the body tag is plain black, but the html tag gets the default white. By just adding a little CSS the problem is solved:

html {
background-color: #000;
}

And the result looks better.

Portfolio with html tag styled
html tag with styling

This also allows us to remove the wrapper-div container for even cleaner HTML as explained here, IF you don’t need to support Internet Explorer 5!

No Responses to “html tag and XHTML”.

Comments are closed.