Reply Thread Tools Search this Thread
Old 12-04-2012, 10:10   #1 (permalink)
Alex{R}
Code Monkey!
 
Alex{R}'s Avatar
 
Join Date: Nov 2009
Location: Россия
Posts: 191
Send a message via ICQ to Alex{R} Send a message via MSN to Alex{R} Send a message via Yahoo to Alex{R} Send a message via Skype™ to Alex{R}
Need help creating Custom HTML Tags

Hi guys,

I'm looking into creating my own custom html tags. Using Google Search, I've found and read several articles on the matter and I'm still having trouble understanding the concept. I know it would not be considered html anymore if they are custom, but I would still like to do this. Can anyone help?

Generally what I would like to do is have custom tags used on my website. So instead of using the <div> or <span> tag, I would like to have <job> or <address> but have them behave as <div> or <span> tags.

I know it's possible, but I don't know how to do it. I've read some where that you can just create a custom tag, and style it via css. I've tried this as a test, and it did not work. Am I missing something?

Any help on this matter would be greatly appreciated.
  Reply With Quote
Old 12-04-2012, 10:12   #2 (permalink)
Limbo
My van, my rules.
 
Join Date: Feb 2005
Posts: 23,302
Why?

HTML5 doctype has a better selection of tags - use those?
  Reply With Quote
Old 12-04-2012, 10:23   #3 (permalink)
ian
éireannach
 
ian's Avatar
 
Join Date: Sep 2009
Location: Düsseldorf, Deutschland
Posts: 1,957
I second Limbo here, why do you want to do this? You really need to examine why you think this is required before you decide to do it.

Perhaps using existing tags with Mircoformats would be better?

Most browsers will render any tag you want. Except older versions of IE of course. For them you'll need to do something similar to what the HTML5 shiv does for HTML5 tags which creates tags that the brower doesn't know about via JavaScript.
__________________
  Reply With Quote
Old 12-04-2012, 10:24   #4 (permalink)
Alex{R}
Code Monkey!
 
Alex{R}'s Avatar
 
Join Date: Nov 2009
Location: Россия
Posts: 191
Send a message via ICQ to Alex{R} Send a message via MSN to Alex{R} Send a message via Yahoo to Alex{R} Send a message via Skype™ to Alex{R}
Quote:
Originally Posted by Limbo
Why?

HTML5 doctype has a better selection of tags - use those?

I already do.. But I want to use custom tags for some things in my project. I know it wont do anything for me, but it would be great to learn how to do it.
  Reply With Quote
Old 12-04-2012, 10:43   #5 (permalink)
teapoted
~
 
Join Date: Feb 2008
Location: London
Posts: 7,091
Custom elements, not tags.
__________________
  Reply With Quote
Old 12-04-2012, 10:44   #6 (permalink)
Sherbs
Oo-ee-oo
 
Sherbs's Avatar
 
Join Date: Feb 2010
Location: Essex, UK
Posts: 2,689
I've tried it before and it does work.
  Reply With Quote
Old 12-04-2012, 10:47   #7 (permalink)
ian
éireannach
 
ian's Avatar
 
Join Date: Sep 2009
Location: Düsseldorf, Deutschland
Posts: 1,957
Quote:
Originally Posted by teapoted
Custom elements, not tags.

Well they're not exactly the same thing, <div> is a tag is and an element is the tag and its content. A tag can exist without an element but not vice versa.

But I'm sure you know that!
__________________
  Reply With Quote
Old 12-04-2012, 10:47   #8 (permalink)
Alex{R}
Code Monkey!
 
Alex{R}'s Avatar
 
Join Date: Nov 2009
Location: Россия
Posts: 191
Send a message via ICQ to Alex{R} Send a message via MSN to Alex{R} Send a message via Yahoo to Alex{R} Send a message via Skype™ to Alex{R}
Quote:
Originally Posted by Sherbs
I've tried it before and it does work.

Care to elaborate?..
  Reply With Quote
Old 12-04-2012, 10:51   #9 (permalink)
teapoted
~
 
Join Date: Feb 2008
Location: London
Posts: 7,091
Quote:
Originally Posted by ian
Well they're not exactly the same thing, <div> is a tag is and an element is the tag and its content. A tag can exist without an element but not vice versa.

But I'm sure you know that!
Yeah, so what he wants is an element =P
__________________
  Reply With Quote
Old 12-04-2012, 12:18   #10 (permalink)
Sherbs
Oo-ee-oo
 
Sherbs's Avatar
 
Join Date: Feb 2010
Location: Essex, UK
Posts: 2,689
HTML Code:
<!DOCTYPE html> <html lang="en"> <head> <style> flibble { background-color:orange; } </style> </head> <body> <flibble>wank</flibble> </body> </html>
  Reply With Quote
Old 16-04-2012, 07:24   #11 (permalink)
jhonpaul
Registered User
 
Join Date: Apr 2012
Location: delhi
Posts: 3
The tag functionality is accomplished with a JavaScript class attached to it. When this class is instantiated, the corresponding object provides functionality of the tag.

One sample implementation for “myfield” tag is defined here. You can create this in “my_common_library.js”, with the rest of your custom tags.

This class takes one argument which is the object passed from the JavaScript function that initializes the process we will get to the function that triggers the initialization process in a moment.
  Reply With Quote
Old 16-04-2012, 07:59   #12 (permalink)
ian
éireannach
 
ian's Avatar
 
Join Date: Sep 2009
Location: Düsseldorf, Deutschland
Posts: 1,957
Begone fool.
__________________
  Reply With Quote
Old 24-04-2012, 06:28   #13 (permalink)
Alex{R}
Code Monkey!
 
Alex{R}'s Avatar
 
Join Date: Nov 2009
Location: Россия
Posts: 191
Send a message via ICQ to Alex{R} Send a message via MSN to Alex{R} Send a message via Yahoo to Alex{R} Send a message via Skype™ to Alex{R}
Quote:
Originally Posted by ian
Begone fool.

that's not very nice.

... anyways, thanks everyone that helped in clearing this question and pointing out the pros and cons to doing this. Obviously this is not good practice as a web developer, but it's always good to learn the possibilities of creating something unique.
  Reply With Quote
Old 24-04-2012, 08:02   #14 (permalink)
ian
éireannach
 
ian's Avatar
 
Join Date: Sep 2009
Location: Düsseldorf, Deutschland
Posts: 1,957
Quote:
Originally Posted by Alex{R}
that's not very nice.

I wasn't referring to you.
__________________
  Reply With Quote
Old 24-04-2012, 12:59   #15 (permalink)
calder12
Senior Member
 
calder12's Avatar
 
Join Date: Apr 2011
Location: Ontario, Canada
Posts: 11,023
haha
  Reply With Quote
Old 10-05-2012, 21:54   #16 (permalink)
dug
the bug.
 
dug's Avatar
 
Join Date: Oct 2007
Posts: 120
This might not be what you're looking for but by chance I was looking into the createElement() function in Javascript today. So what this guy did was make a script to create all the elements in HTML5 so you could put the script in <ie9 and have basic HTML5 support.

HTML5 enabling script
  Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive
vBulletin © 2000-2009 Jelsoft Enterprises Limited.
Search Engine Optimization by vBSEO 3.0.0 RC8