Close Your Tags in XHTML

During some conversations today, I found out that neither my experimental site nor my regular site was rendering in Mozilla. The culprit is not a new one. I had added some formatting to the page and forgot to close my tags.

If you’re going to strive for XHTML compatibility, then remember to correctly close your tags! In the case of a block of text, that’s as simple as omitting the closing </div> (or perhaps adding one too many of them – as was my case).

Don’t forget the <head> of your page, either. I had added a new <link> and forgot to close it. Close a link tag, you say? You don’t close a link tag! In the case of XHTML, you most certainly do close a link tag. You close every tag.

If you’re working with a tag that doesn’t typically have a closing tag, such as <br> or, as was my case, <link>, then you’ll need to make a simple adjustment to the end of your single tag. Instead of <br>, use <br />. Instead of <link>, use <link />. Do it while you’re writing the code. It’s so much simpler than going back later to try and find the problem!


Posted

in