views:

1494

answers:

5

What is the use case for using your own html tags? (In standard off the shelf browsers)

A colleague and myself were discussing it lately. I could not think of a use case. We discussed it could be used for styling with css but then decided to use the span tag with a class instead.

Thanks Paul

+1  A: 

I think classes are an excellent idea. They are commonly used for CSS, but the W3C specification allows them for other uses too. Microformats are a great example of using classes for data purposes.

harriyott
A: 

I must confess I don't know a great deal about creating custom tags, but I did remember ALA published some useful articles on the subject - customd2ds is pretty good.

Sam Murray-Sutton
I should add, it would be great to know if anyone did have a good use case for custom tags/doctypes in web development.
Sam Murray-Sutton
Thanks for the link Sam interesting stuff
Paul Whelan
+5  A: 

There is no good reason to use your own HTML tags. At least because once you start using your own tags it's not HTML anymore.

If you need an extensible markup language for semantic purposes, use XML to model your data and XSLT to render your document to HTML.

On the HTML side, if you need to distinguish a set of elements with specific CSS rules, the right approach is to:

  • Pick the HTML element that is semantically closest to what you need. The SPAN and DIV elements are popular for this purpose, but are semantics-free and other phrase elements are sometimes more appropriate.
  • Add a class attribute. Note that this attribute is a space-separated list of names. So you can assign multiple classes to a single element.
  • Use the CSS class selector to associate the desired formatting to the elements.
ddaa
Thanks for the detailed response
Paul Whelan
A: 

We generally get lot of requirements to create tools and calculators for the website. Since this needs to be implemented across multiple pages and also multiple domains, we had to create our own library of fields which takes care of input entry formatting, validations and binding to a JSON object. A simplified implementation is described here. http://hubpages.com/hub/extented-HTML-tags

ajay
A: 

I use custom tags in my Safari extension to wrap a text injected to the page.

The extension must work on any web site and this way I avoid the problem span tag (the natural choice otherwise, look at GoogleTranslate) may be subject of some CSS rule used on that site.
So I basically use "unique" tag name for that.

Yurii Soldak