If you are trying to write valid XHTML 1.0, whether it is transitional or strict, you must close all tags. That even includes input, br and img! It is perfectly valid to use the shorthand closing though if you don’t need anything inside the tag. Eg.
<br />
<img src=”image1.jpg” />
<input type=”text” name=”user” />
This might sound pedantic, but if you do write truly XHTML compliant pages, it removes the need for a lot of extra preprocessing on whatever is trying to read them, and it also removes a lot of ambiguities which can cause strange rendering. This means that a lot more tools, bots and systems can read them, and there can be all sorts of benefits. It also makes it a lot easier on accessibility clients such as screenreaders so that your visually impaired readers can still read your pages.
No related posts.
Tags: HTML, Standards Compliance












[...] thing to remember if you want to be XHTML compliant (see Closing all Tags in HTML) is to make sure that all your attribute values are in quotes. eg. height=”100″ and not [...]