| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Code Monkey!
|
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. |
|
|
|
|
|
#3 (permalink) |
|
éireannach
Join Date: Sep 2009
Location: Düsseldorf, Deutschland
Posts: 1,949
|
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. |
|
|
|
#7 (permalink) | |
|
éireannach
Join Date: Sep 2009
Location: Düsseldorf, Deutschland
Posts: 1,949
|
Quote:
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! |
|
|
|
|
#9 (permalink) | |
|
~
Join Date: Feb 2008
Location: London
Posts: 7,102
|
Quote:
|
|
|
|
|
#11 (permalink) |
|
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. |
|
|
|
#13 (permalink) | |
|
Code Monkey!
|
Quote:
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. |
|
|
|
|
#16 (permalink) |
|
the bug.
Join Date: Oct 2007
Posts: 118
|
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 |
|
![]() |
|