I was trying to make an HTML page and I used:
<img src="something.png"></img>
and
<img src="something.png"/>
Which are both valid XML and and it didn't display. But if I left off the trailing slash or left off the closing tag it worked.
<img src="something.png">
Which is not valid XML. I've found numerous examples of these tags including, "BR" and a few others (possibly UL or OL) that are invalid XML or strange behavior (layout?) when closing them.
I want to make my HTML markup valid XML but have it display in older browsers. I've looked at and heard of XHTML but heard that it is deprecated but I'm not sure. I've tried it and in fact it rendered differently than my HTML page.
My question is, is it possible for me to make my HTML page markup also valid XML and still work in older browsers (not super old but old).
UPDATE:
I've tested the above tags and I have not been able to reproduce the issues (might have been doctype or older or mobile browser). As I was testing I came across another example though. I was using valid XML singletons in many places but they were not loading. I found this case mentioned on Wikipedia:
<script type="text/javascript" src="/script/site.js"/>
Note: The format
<script …></script>
, rather than the more concise<script … />
, is required for HTML compatibility when served as MIME type text/html (from wikipedia)
Background Info:
The reason for this is because I have XML validators at my disposal and it has been great for catching typos and errors. I would much rather write well formed HTML for this reason alone.
The other reason for this is that I'm working on generating some HTML and internally it would be much easier to work with an E4X XML object than writing strings because XML objects have a toXMLString() method which writes the formatted XML out for me but it will make singleton nodes <node />
which, as mentioned above, do not work with some tags (such as the script tag).