Back in the day, I remember writing many a webpage without using / in the
tag. What changed? Also, is the space "required?"
|
|
|||||
|
I have great news for you! You don't need no steenking / any longer. Again, I mean. Why? Because ...
XHTML, an implementation HTML serialized as XML. XML has a very strict set of syntax requirements. One of those requirements is that you can't leave a tag open. The syntax
One of the more interesting things about XHTML is that it's kind of backwards compatible with HTML. You can throw a legal XHTML document at an HTML parser and it should be able to make sense out of it. However, not all HTML parsers can do so. Old, old, prehistoric, no-longer-used versions of Netscape and other browsers would see the self-closed There's a fatal flaw with XHTML. Because it requires the XML parsing rules, that also means it requires the XML error handling rules, which mandate that parsing halt immediately upon a syntax error. In other words, if there's a single parse error in the document, the browser must not show the document to the user. That's kind of a show-stopper. XHTML served as XML never caught on because some browser vendors (like Microsoft) refused to add support due to the must-die-immediately nature of error handling. XHTML still caught on because it was full of awesome best practices, even if the documents didn't end up being served as XML. Now, earlier I said that you don't need it any longer. That is true for both HTML4 and the upcoming HTML5. They've gone through the effort of actually specifying how HTML5 should be parsed now, and that forward slash is going to be considered an error. Thankfully XHTML5 is a thing, and if you really want to use the XML syntax rules instead of the HTML5 syntax rules, you can go right ahead. |
|||||
|
|
It's required for XHTML compliance:
Read the section under the heading: "Relationship to HTML" for more info. |
|||||||
|
|
like
In the case where there was no closing tag (like single tags as As for the space: It is not required. And when it comes to what changed. It is all about HTML itself. As HTML 5 gains more popularity every day people are using In HTML 5 |
|||
|
|
|
As has been said, the trailing slash is used to close empty elements (e.g. br, hr, img), and is required when writing pages using the XHTML doctype. The space is not required, but was commonly used since some older browsers (I think including Netscape 4) did not like empty elements having a trailing slash without the space. So the space became common use to accommodate the browsers that didn't fully understand XHTML. It's not required now. |
|||
|
|
|
|
|||||||||||
|
