How do I acheive a perfect, zero error, fully validated polyglot syntax. If I follow the following, will it acheive it?

1 - Include the XML declaration

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

2 - Serve it as application/xhtml+xml MIME type

<meta htt-equiv="Content-Type" Content="application/xhtml+xml; charset=UTF-8" />

3 - Include the xmlns and xml:lang attributes

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="eng">

4 - lower case for elements/tags and attributes

<p class="main">Just a Paragraph. Nothing to see here</p>

5 - Single or double quotes for attributes values

<h1 id="first">Just a Heading</h1>

6 - No Attribute Minimazation

<video src="mylife.mpeg" controls="controls">You Browser Does Not Support HTML5 Video</video>

7 - Close all elements/tags. Close empty/void elements/tags with self closing "/>"

<img src="mypic.png" alt="My Picture" />

8 - Close nested elements/tags in the reverse order they were opened

  <li>Just a Item</li>

9 - Use CDATA for embedded Javascript

10 - Always include the DOCTYPE

11 - Use entity references for reserved chracters

12 - Make sure that there is only one root element and that root elemnet is html

Will the above be enough for my purpose. I am well aware of the pontential pitfalls for each point. Despite them, If I really want to, will I be able to acheive it while keeping it backward comptible and progressive enchament.

  • Any Body? over 8 years ago

1 answer

Ktash 1851

I think I might be confused as to what exactly you are looking for with a polyglot syntax. Or, maybe I should say, I think I may be confused as to why you are looking for one. So, I may be stating the obvious here, and don't be offeneded one way or the other, but I'll try to answer as best I can. I'll also correct/update as needed.

So, the first thing to talk about is the goal. From your last line

...will I be able to acheive it while keeping it backward comptible and progressive enchament

I'm thinking your goal here is to be compatible with as much as possible. If you are working with just browsers, the easiest way to do that is via a doctype. And, more specifically, all you need is

<!DOCTYPE html>

and you have a fully valid page with HTML4+ and all browsers across the board. But the inclusion of XHTML and XML in here makes me think there is a possibility for needing to use an XML parser, or something of those sorts, in which case, you'd need to change <html> to be <html xmlns="http://www.w3.org/1999/xhtml">, but that then invalidates in HTML 4.x. So that's something you'd need to consider.

As for items 4-12 (with 10 being discussed above), those are just good practice things to do anyway.

Answered over 8 years ago by Ktash