954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Inventing your own HTML codes

I am wondering is it possible to invent your own HTML codes? For example there are basic tags like , , etc etc etc. I'd imagine one would need some sort of programming skills to do this, but would like to know some thoughts on this :).

nzcreativeweb
Newbie Poster
3 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

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
Banned
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
 

Cheers for the advice, I don't know all that much about programming etc I am more geared towards web design although I know there are some good benefits for a web designer having that knowledge.

nzcreativeweb
Newbie Poster
3 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

You can simply define your own tags using a plain XML document, and then collaborate its way using simple scripts that will evaluates your tags on the browser.

Here's simple tag examples created in plain XML document format:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE myevents [
<!ELEMENT myevents (event*)>
<!ELEMENT event (#PCDATA|hour|minute|info)*>
<!ELEMENT hour (info)>
<!ELEMENT minute (info)>
<!ELEMENT info ANY>
<!ATTLIST hour 
         id ID #IMPLIED
         name CDATA #IMPLIED
         set CDATA #REQUIRED 
         off CDATA #FIXED "0">
<!ATTLIST minute 
         id ID #IMPLIED
         name CDATA #IMPLIED
         set CDATA #REQUIRED 
         off CDATA #FIXED "0">
]>
<myevents>
<event>
<hour id="hOne" name="hOne" set="1">
<info>event&apos;s that take place if the current hour is 1</info>
</hour>
<minute id="mOne" name="mOne" set="1">
<info>event&apos;s that take place if the current minute is 1</info>
</minute>
</event>
<event>
<hour id="hTwo" name="hTwo" set="2">
<info>event&apos;s that take place if the current hour is 2</info>
</hour>
<minute id="mTwo" name="mTwo" set="2">
<info>event&apos;s that take place if the current minute is 2</info>
</minute>
</event>
<!-- 
* You must provide a lists of 12 <event> elements here including (hour | minute) enclosed in its collection.

* Those 12 <event> elements will be used as our pointer to get specific event(s), which will be displayed in the page. This elements is referenced with the JavaScript date object's ( getHours() and getMinutes() ) -->
</myevents>

I've created this tags (document) for timekeeping events in my site, and generated usingAJAX to display whatever the issue i have on created tags.

Hope it helps...

essential
Posting Shark
974 posts since Aug 2008
Reputation Points: 114
Solved Threads: 138
 

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
 

Strange things happen if you try something. In IE6 it doesn't seem to work, but in Firefox 2 and 3 the following works:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
     <title>Strange</title>
     <style type="text/css">
          mytag	{color:green}
     </style>
</head>
<body>
     <mytag>some text</mytag>
</body>
</html>


The text is displayed in green. :D

colweb
Posting Whiz
318 posts since Nov 2007
Reputation Points: 34
Solved Threads: 52
 

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
Moderator
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

Found it! Here's an example of HTML with custom attributes, which are read and acted on by javascript in response to user events.

http://www.daniweb.com/forums/thread189876.html#post859842

Airshow

Airshow
WiFi Lounge Lizard
Moderator
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You