473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

custom tags and elements

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)

Andy


Dec 5 '06 #1
11 2248
Andy Fish wrote:
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)
If you want to put extra data into a web page for use by javascript why
not put it inside a SCRIPT element, probably in a structure made up of
Array and Object literals (as anything that can be represented with a
mark-up tree can also be represented in such a form).

Richard.

Dec 5 '06 #2
On 2006-12-05, Andy Fish <aj****@blueyonder.co.ukwrote:
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)
You can just use div in conjunction with some class name and use CSS to
set display: none for divs of that class.

div.data
{
display: none;
}

<div class="data">
....
</div>
Dec 5 '06 #3
"Andy Fish" <aj****@blueyonder.co.ukwrote:
>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)
What is it that you are actually trying to do?

--
Spartanicus
Dec 5 '06 #4

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 <divor <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.

Dec 5 '06 #5
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 <atags, so I will use my own custom attribute.

Andy

"Andy Dingley" <di*****@codesmiths.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
>
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 <divor <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.

Dec 5 '06 #6
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)
Dec 5 '06 #7

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...8e7028fa7fa1/#

Dec 5 '06 #8
In our last episode,
<Zn******************@text.news.blueyonder.co.uk >,
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.
Dec 5 '06 #9
Scripsit Ben C:
You can just use div in conjunction with some class name and use CSS
to set display: none for divs of that class.
Among the different suggestions that have been made, this is definitely the
worst. It would mean that any CSS-disabled user agent sees the data as
normal content. This includes search engines.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Dec 6 '06 #10
In article <Rf******************@text.news.blueyonder.co.uk >,
"Andy Fish" <aj****@blueyonder.co.ukwrote:
in this case, I just want to store a single extra string value alongside
some of the <atags, so I will use my own custom attribute.
After finding too many problems with trying to use an element for a blog
entry, I used the title attribute in my anchors to store information
about each entry (for potential future use by an indexing system). While
using title means the title contents are normally visible if you hover,
in this case it isn't a problem, since there is no reason someone
browsing a blog shouldn't be able to see the categories I was using.

<h3><a name="20061202a" title="categories computers media">Sony being
Weird</a></h3>

Seems valid, and doesn't seem to me to warp semantics too much.

--
http://www.ericlindsay.com
Dec 7 '06 #11
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)
form. It can have input[type="hidden"] descendants where you can store your
data, and it can also have nested elements as descendants. Might not be
pretty, but works smoothly as long as nobody submits the form without a
submit button.

You could also use a `meta' element.

Note that these are not general recommendations for a solution. I am merely
pointing out the options you have within the given constraints.
PointedEars
--
Let us not judge others because of their religion, color or nationality.
We are all just human beings living together on this planet. (poehoe.de)
Dec 11 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris | last post by:
Im hoping someone can help me understand why this works? Requirement: Navigate DOM through javascript to perform DHTML actions. Issue: GIANT html document, up to 4MB in size, thousands and...
8
by: Hostile17 | last post by:
Consider the following HTML. ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <meta...
5
by: Bauke Jan Douma | last post by:
Hi, I am just starting to get familiar with all the ins and outs of html. I noticed that you can define a style, e.g.: x {color: green; font-weight: bold} and then use <x> and </x> tags in...
1
by: Jenny | last post by:
Hi, Can I create an array of tags by assigning same name to these tags? For example, I have two <p> tags with the same name t1. But document.all.b.value=document.all.t.length does not...
2
by: alex bazan | last post by:
I'm building a cross-browser XML dataisland. This code works perfectly in mozilla, but i have problems with explorer. it tells me that: "diXML.getElementsByTagName(..).0 is null or not an...
1
by: Christian H | last post by:
Hi! I'm wondering how I can add extra html to a radiobuttonList, so that I can control how: -the whole radioButtonList is rendered. -each of the radiobutton elements are rendered. What I am...
3
by: serge calderara | last post by:
Dear all, Let say that I have developped a funcionnal library that I distribute for use. That library can be integrated in a project by referencing it and then use it by calling function and...
10
by: Andy Fish | last post by:
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...
0
by: mk189 | last post by:
Hi, I am trying to create XML schema of custom markup language, enriched by XHTML. In simplified version, the XML documet could look like that: <a:alarm-manual xmlns:a="alarm-manual"...
1
Gulzor
by: Gulzor | last post by:
Hi, I have defined a set of custom tags that I put among regular HTML tags. E.g. <body> <div id="regular_id"> <namespace:container id="something" type="article" /> </div> </body>
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.