You are here: Re: Defining Your Own Attribute in an HTML Tag « HTML « IT news, forums, messages
Re: Defining Your Own Attribute in an HTML Tag

Posted by Benjamin Niemann on 10/17/70 11:49

Herman wrote:

> Is it illegal to define your own attributes that are not defined by
> HTML standards?

You won't go to jail for it, but it is invalid.

> It sounds stupid, but would this work:
>
> <td id='cell' info='Information stored here'>

I would not call it 'info', chances are to high that this will clash with
future HTML versions (ha ha) or browser specific extensions. Call it
e.g. 'xHermanInfo' (a more conventional 'x-herman-info' would be allowed as
an attribute, but will cause trouble in JS...)

> Then in javascript:
>
> var info = document.getElementById('cell').info;

This may or may not work. Browsers are free to ignore tags and attributes
that they do not understand, so your info attribute may not end up in the
DOM. Hey, but this is JavaScript, so you write your scripts anyway in a way
that degrades gracefully, if required features are not available... You do?

> The attribute wouldn't have an effect on the element itself, but it
> would act as an information holder for the particular element.
> This idea to me screams conflict with W3 standards, but its an idea
> that would seemingly make things easier for me.
> Any thoughts?
> Thanks a lot.

You can get the same (if the information is always accessed by the elements
ID) by using a JavaScript array that maps 'cell' -> 'Information stored
here'.

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация