W3C has ended support for the polyglot markup. So do I have to convert my site to use regular HTML5 instead of XHTML? How would them abandoning this concept affect existing sites? I want to have a perfectly valid markup and if that code conflicts with what is the standard, I will have to remove it.
As usual more bashing in comments against XHTML without any true comprehension of what it is.
You can and should use the strictest tools available to you. In example in PHP you should always check if a variable isset
. Why? Hackers will remove an input
element from a form, submit the form and then try to see what error messages the server would send. But if you lower the strictness of PHP's error messages you would think everything is fine and dandy.
I saw a guy stress out for three days over why only Safari wouldn't render a certain style correctly. If he had used the XML parser the page would have (in Firefox) completely failed and he would have gotten an error message pointing out exactly what the error is, what line it's on and what column on that line (other browsers render up to the line so use Firefox for testing by default). His error? He was missing a double quote around one of his attributes; the screen door was wide open on his submarine.
This does not imply you can't use HTML5 because we're talking syntax here. Ideally you should be using XHTML5, HTML5 using the XML parser. It doesn't catch all issues (duplicate id
attribute values in example) though it will require you to code on a higher level.
Yeah, IE8 doesn't support XHTML (it kind of supports XML) but it's not even worth considering supporting IE8. Frankly it's the only browser that has any "significant" market share that doesn't support XHTML though this doesn't mean you can't do content negotiation:
<?php
if (stristr($_SERVER['HTTP_ACCEPT'],'application/xhtml+xml'))
{
header('Content-Type: application/xhtml+xml');
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
}
?>
Keep in mind that IE8 will render in quirks mode if it sees the XML declaration though as of 2016 that is a moot point since it's no longer a browser worth supporting unless you're being paid as a specialist specifically to deal with that browser.
My whole platform uses XHTML5 and it has greatly improved standards, development time and skillset. Always question the integrity of people who speak against doing something that requires more skill, there is a reason why the saying a dime a dozen exists.
If you're looking for a quick way to adapt usage of the XML parser though don't have the time to replace dozens or hundreds of <br>
in example I highly recommend considering Advanced Find and Replace. Pick a directory, one or several file types (e.g. *.php;*.css;*.xml
) and the code you want to find and then what to replace with. Additionally it actually runs faster emulated via Wine that Linux's native grep
command and it's super cheap. Do be careful how you do mass find-and-replaces though, the stricter your code's white-space the better off you'll be and always back things up first!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With