Click here to get back home

custom tags and elements

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
custom tags and elements Andy Fish 12-05-2006
Get Chitika Premium
Posted by Andy Dingley on December 5, 2006, 6:19 am
Please log in for more thread options



Andy Fish wrote:

> I would like to include extra "hidden" information in a generated HTML page
> that can be used by javascript functions.

Then put it in JavaScript.


> I realise that most browsers seem to ignore any tags and attributes they
> don't understand,

No, they ignore unknown attributes. They will still process unknown
tags (they show you their content) even if the "tag" appears not to
have any effect. This behaviour is pretty reliable.


> but from what I can tell the standards do not allow me to
> make up my own tags or attributes as they will fail validation.

You'll be able to do this cleanly with XML and namespacing, but that's
still a long way off.

> is there any standard element name that can be used for such a purpose

In general, it's enough to use the existing elements and almost always
to stick with the standard attributes too. You can achieve most of what
you need with the class or id attributes. These values can then be
lookup indexes into JavaScript arrays for more detail. You can even use
anodyne elements like <div> or <span>, added where necessary just as
carriers for these attributes.

I'd happily add attributes if I really needed to, or it made the code
clearer. I wouldn't add elements though.


Posted by Andy Fish on December 5, 2006, 7:05 am
Please log in for more thread options


thanks andy (and others) for the replies

I guess the best solution in the general case would be to store extra stuff
in javascript structures indexed by element ids. I hadn't really thought of
this.

in this case, I just want to store a single extra string value alongside
some of the <a> tags, so I will use my own custom attribute.

Andy

>
> Andy Fish wrote:
>
>> I would like to include extra "hidden" information in a generated HTML
>> page
>> that can be used by javascript functions.
>
> Then put it in JavaScript.
>
>
>> I realise that most browsers seem to ignore any tags and attributes they
>> don't understand,
>
> No, they ignore unknown attributes. They will still process unknown
> tags (they show you their content) even if the "tag" appears not to
> have any effect. This behaviour is pretty reliable.
>
>
>> but from what I can tell the standards do not allow me to
>> make up my own tags or attributes as they will fail validation.
>
> You'll be able to do this cleanly with XML and namespacing, but that's
> still a long way off.
>
>> is there any standard element name that can be used for such a purpose
>
> In general, it's enough to use the existing elements and almost always
> to stick with the standard attributes too. You can achieve most of what
> you need with the class or id attributes. These values can then be
> lookup indexes into JavaScript arrays for more detail. You can even use
> anodyne elements like <div> or <span>, added where necessary just as
> carriers for these attributes.
>
> I'd happily add attributes if I really needed to, or it made the code
> clearer. I wouldn't add elements though.
>



Posted by Andy Dingley on December 5, 2006, 2:35 pm
Please log in for more thread options



Andy Dingley wrote:

> In general, it's enough to use the existing elements and almost always
> to stick with the standard attributes too. You can achieve most of what
> you need with the class or id attributes.

Read this thread for an interesting example of the technique (and use
of the rel attribute)
http://groups.google.co.uk/group/alt.www.webmaster/browse_frm/thread/445d8e7028fa7fa1/#


Posted by Jim Moe on December 5, 2006, 2:13 pm
Please log in for more thread options


Andy Fish wrote:
> is there any standard element name that can be used for such a purpose i.e.
> passes validation but never produces any output (and ideally allows nested
> elements to be rendered normally too)
>
<input type="hidden" id="secretid" name="my-hidden-name"
value="my-hidden-data">

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

Posted by Lars Eighner on December 5, 2006, 3:54 pm
Please log in for more thread options


In our last episode,
the lovely and talented Andy Fish
broadcast on comp.infosystems.www.authoring.html:

> Hi,

> I would like to include extra "hidden" information in a generated HTML page
> that can be used by javascript functions.

> I realise that most browsers seem to ignore any tags and attributes they
> don't understand, but from what I can tell the standards do not allow me to
> make up my own tags or attributes as they will fail validation.

> is there any standard element name that can be used for such a purpose i.e.
> passes validation but never produces any output (and ideally allows nested
> elements to be rendered normally too)

DIV and SPAN are the general block and inline elements respectively. To the
best of my knowledge, there is not a general empty element, although I have
long thought it would be a good idea if there were.

There are some places where absolutely nothing except white space or
comments is allowable. For example, you cannot put anything in TR
except TH or TD, so you cannot put any other naked element in TR, but I
think in most cases you can use DIV or SPAN if you are care to choose
which is allowable in the context. You cannot, of course, just make up
attributes, but you certainly can code information in CLASS and ID.

As for "never produces any output," it isn't clear to me what that means.
Do you mean you don't want the contents of the element rendered? In that
case you can style the element for display: none, but of course that doesn't
hide the contents from the browser, it only suggests that styles-enabled
browsers not render it. Or do you mean that you do not want the element to
be rendered differently because of the element? In that case, simply don't
style the element and, if you have chosen rightly between DIV and SPAN,
the appearance of the rendered document will not be changed.


--
Lars Eighner <http://larseighner.com/> <http://myspace.com/larseighner>
Cole's Law: Thinly sliced cabbage.

Similar ThreadsPosted
Style tags -- Eeek how obese these tags make HTML! November 8, 2006, 3:33 am
Custom meta name="xxx" October 31, 2007, 7:19 am
Custom Software Development May 20, 2007, 7:14 am
Meta Tags, Link Tags, other September 27, 2005, 3:29 pm
Adding custom attributes through XMLSchema November 4, 2005, 6:55 pm
custom January 20, 2006, 12:52 pm
xhtml, custom dtds, and MIME types January 27, 2006, 2:34 pm
Google Custom Search Engine, what type of ID? November 11, 2007, 9:02 pm
style defining custom made tag: is this portable?: x {foo: bar} Hello world July 8, 2004, 7:40 pm
Unknown Parse Mode! warning from w3c validator with custom doctype September 6, 2005, 11:23 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap