6

I have a friend who has the specific problem of building a case against the use of a custom HTML <wrapper> tag in some site's markup. Now, intuitively we can answer that use of such a tag is risky, as future HTML specs may define a wrapper tag with semantics that conflict with its use on the site. We can also appeal to a particular section of the HTML5 spec which also recommends against the use of custom tags for this reason.

And while I agree with the conclusion, I find these arguments a little on the weak side, on their own. Is there some well grounded and proven theory in computer science from which we can derive this conclusion? Have programming language theorists created proofs about the properties of vocabulary versioning, or some such thing?

Breton
  • 169
  • 5
  • 3
    I don't know your answer but why is it weak if a specification says 'Don't do this'? – Uwe Plonus Dec 12 '12 at 07:13
  • 5
    No well founded theory, but something which might be of interest in your case: http://www.joelonsoftware.com/items/2008/03/17.html – Doc Brown Dec 12 '12 at 07:16
  • 1
    i could point out that the legitimacy of the HTML5 spec is not universally accepted. but, setting that aside, the problem with the argument is it's a circular appeal to authority. this is bad because it is bad, and this authority says it is bad. the underlying reasoning and evidence is not thoroughly presented. there may not be something akin to a mathematical proof, but there seems to be some core set of compatibility principles that many smart engineers and language designers agree on. i wonder if they are codified anywhere – Breton Dec 12 '12 at 07:47
  • 2
    "the legitimacy of the HTML5 spec is not universally accepted" ?! – AakashM Dec 12 '12 at 09:06
  • You sound overly stubborn, just admit your defeat. Can you disprove that someone with authority towards the spec will at some moment in the future introduce a element? No you can't, how much more science do you need? – Joppe Dec 12 '12 at 19:53
  • Have you really never heard the argument "BUT IT IS ONLY A DRAFT!"? "How much more science do you need?" I want to find some well founded general principle that could be applied beyond just this one specific case. – Breton Dec 13 '12 at 00:14
  • @DocBrown I am sorry I was not more attentive about this last month when I originally asked the question, but now I've taken the time to read your link, you have hit the nail on the head. thanks. – Breton Jan 19 '13 at 10:17

1 Answers1

4

There is a mechanism in XML that allows for the kind of extension that you are doing, and avoids the conflict by allocating tags in specific namespaces. To use this, you need to use the XHTML syntax encoding of the HTML5 vocabulary. (See HTML vs. XHTML.)

What it allows you to do is to declare a namespace (which looks like a URL) and a token (e.g. "mx" for "my extension"). You need a namespace declaration at the top that associates the namespace with the token. (See Declaring Namespaces.)

 <html ...  xmlns:mx="http://mycompany/myextension" ... >

Then, instead of defining a <wrapper> tag, you define a tag <mx:wrapper>

Because of the token, and colon, you can never conflict with an official HTML tag, because those tags are in a different namespace. (See Namespaces of HTML5.)

What about conflicts on the token? Remember that the "mx" is just a local identifier associated with the longer, and globally unique, namespace URL. In another document the token "yob" might be associated with the namespace, and the tag would be <yob:wrapper> in the body of the document.

I don't know if this is the answer that you wanted, but the namespace mechanism is a well proven (if cumbersome) way to mix together tag sets from different standards bodies which necessarily work independently, but need to mix their results together into a single document.

It does require that you use XHTML, instead of HTML syntax, which actually works in most of the browsers I have experience with, in fact I generate exclusively XHTML syntax and have not had problems, but you will need to investigate whether that is suitable in your environment

AgilePro
  • 312
  • 2
  • 7
  • I am not that green around the ears. I know all about XML namespaces already. I appreciate the thoroughness and thoughtfulness of your answer. I thank you for taking the time to answer. But you kind of missed the point of my question by a mile. – Breton Jan 19 '13 at 10:13