Very much possible but you need come up with your own browser which will interpret your tags the way you want.
ithelp
Nearly a Posting Maven
2,230 posts since May 2006
Reputation Points: 769
Solved Threads: 128
going further, if you start to look at server-side languages, JSP for example, lets you define your own custom tags. If you do this in JSP, you don't need the browser to interpret your "invented" tags.
sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
You can write your own DOM, if you know how. But your site has to serve it too.
MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
You can do this in HTML:
<custom myAttrib="Hi there">Custom Inner Stuff</custom>
Browsersshould just ignore the custom tag and its atributes, and hence they should display the "inner stuff" as if the tag wasn't there. Not much use except for colweb's point about FF honouring CSS directive - interesting. I wonder if IE7 and 8 do the same?
Custom attributes (of a regular or custom tag) may be of use to a script:
var c = document.getElementsByTagName('custom');
if(c.length){
alert(c[0].getAttribute('myAttrib'));//gives "Hi there" reliably cross-browser (afaik).
}
Custom attibutes can be very useful for controlling the bahaviour of scripts from HTML without having to edit the script. This is a whole topic in its own right.
But,
var c = document.getElementsByTagName('custom');
if(c.length){
alert(c[0].innerHTML);//blank in IE6 (and maybe others)
alert(c[0].firstChild);//error in IE6 (and maybe others)
}
Conclusion : HTML custom attributes can be useful. HTML custom tags don't appear to offer anything you can't do with regular HTML tags and their behaviour is not reliable cross browser.
As Essential says, if you want to be inventive, use XML. After all, "XML" is "Extensible Markup Language".
Airshow
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372