473,385 Members | 2,029 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,385 software developers and data experts.

Browser behavior with unknown tags or attributes?

Hi,

I went through the HTML spec without finding the description of what
the browsers behavior should/must be regarding tags or attributes they
don't understand. I did a quick experiment like this:

<mytag style='display:none'>

<h3>Hello</h3>

</mytag>

and to my surprise instead of ignoring the <mytagand </mytag>
alltogether and showing the <h3content, the browser did not display
the content between <mytagand </tag>.

I am working on having some proprietary tags and I need to know what
the specs say about non standard tags.

Any idea of where it is specified?

Thanks

Fred

Sep 29 '06 #1
5 13636
Scripsit fjanon:
I went through the HTML spec without finding the description of what
the browsers behavior should/must be regarding tags or attributes they
don't understand.
The good old HTML 2.0 specification is a great improvement over its
successors in this area, too. It said:

"4.2.1. Undeclared Markup Error Handling

To facilitate experimentation and interoperability between
implementations of various versions of HTML, the installed base of
HTML user agents supports a superset of the HTML 2.0 language by
reducing it to HTML 2.0: markup in the form of a start-tag or end-
tag, whose generic identifier is not declared is mapped to nothing
during tokenization. Undeclared attributes are treated similarly. The
entire attribute specification of an unknown attribute (i.e., the
unknown attribute and its value, if any) should be ignored. - -
- -
Support for notifying the user of such errors is encouraged.

Information providers are warned that this convention is not binding:
unspecified behavior may result, as such markup does not conform to
this specification."

(If you read the full story in the HTML 2.0 spec, with examples, note that
there was no <DIVelement in HTML 2.0.)

Of course, this wasn't _rigorous_, and it's basically descriptive, not
prescriptive (normative); and the idea of notifying users was never
implemented. It's still better than the sloppier prose in HTML 3.2 and HTML
4 specs and formal vagueness in XHTML. (People often say that XHTML does not
tolerate any syntax errors, and they regard this is a key benefit. However,
browsers aren't required to have validating parsers.)

What HTML 4.01 says about the issue is the (non-normative) clause B.1, see
http://www.w3.org/TR/html401/appendi...s-invalid-docs
<mytag style='display:none'>

<h3>Hello</h3>

</mytag>

and to my surprise instead of ignoring the <mytagand </mytag>
alltogether and showing the <h3content, the browser did not display
the content between <mytagand </tag>.
Which browser, for which specific test document? (The DOCTYPE declaration
might matter; probably it doesn't, but still you should specify a full
example.)

Anyway, the practice described in the HTML 2.0 spec means that the <mytag
....and </mytagtags are ignored, and this is what the HTML 4.01 spec
really _means_ in this context. Other processing would indeed be surprising
and undesirable, but technically not wrong. Your document is not an HTML
document, so an HTML user agent may do anything it likes with it, as far as
HTML specs are concerned.
I am working on having some proprietary tags
Well, stop right now and solve the original problem by some other means. If
you need help with the original problem, it might help if you gave a hint of
what the original problem is.
and I need to know what
the specs say about non standard tags.
Now you know, and this should imply that you start looking at some other
direction.

Of course, if you intend to use _widely supported_ de facto extensions, such
as <embedor <nobr>, then the practical question is how widely and how
consistently supported they are and what browsers actually do if they don't
support them. You might even try and make an educated guess on how long the
extensions will be supported; this tends to depend on how widely known and
used the extension is. The specifications are not useful in such an
analysis.

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

Sep 29 '06 #2

fjanon wrote:
I went through the HTML spec without finding the description of what
the browsers behavior should/must be regarding tags or attributes they
don't understand.
Browsers are reliable at safely ignoring unknown attributes.

Their behaviour with unknown tags is variable. You seem to have found
one that ignored the tag itself, but still recognised the attached
CSS. It's hard to say that this is strictly "wrong" (or strictly right
either!), but it's certainly not coding style that should be encouraged.

Sep 29 '06 #3
fjanon wrote:
Hi,

I went through the HTML spec without finding the description of what
the browsers behavior should/must be regarding tags or attributes they
don't understand. I did a quick experiment like this:

<mytag style='display:none'>

<h3>Hello</h3>

</mytag>

and to my surprise instead of ignoring the <mytagand </mytag>
alltogether and showing the <h3content, the browser did not display
the content between <mytagand </tag>.

I am working on having some proprietary tags and I need to know what
the specs say about non standard tags.

Any idea of where it is specified?

Thanks

Fred
If you create your own tags and elements, what do you expect a
widespread, specification-compliant browser to do? The browser
recognizes those tags defined in the W3C specifications. How is it to
recognize and understand your proprietary tags that are not defined in
the specifications. Where will the browser get the tag definition?

More important, if you create Web pages using your proprietary tags how
do you expect your audience to view your pages? The key is "graceful
degradation". This means that the text of the page might still be
displayed but without a layout that reflects the Web author's intended
formatting. However, embedding a recognized element within an
unrecognized, proprietary element (as you have done) could result in
completely hiding the former without regard for CSS styles.

In the end, if a Web page is not compliant with the W3C specifications,
how it is displayed by a compliant browser cannot be predicted. The
GIGO rule applies: garbage in = garbage out.

--

David E. Ross
<http://www.rossde.com/>

Concerned about someone (e.g., Pres. Bush) snooping
into your E-mail? Use PGP.
See my <http://www.rossde.com/PGP/>
Sep 29 '06 #4
David E. Ross:
If you create your own tags and elements, what do you expect a
widespread, specification-compliant browser to do?
Exactly.

While the spec doesn't specify how user agents SHOULD or MUST recover
from errors, it does say (informatively):

| If a user agent encounters an element it does not
| recognize, it should try to render the element's content.
| ...
| We also recommend that user agents provide support
| for notifying the user of such errors.
|
| Since user agents may vary in how they handle error
| conditions, authors and users must not rely on specific
| error recovery behavior.

(sec. B.1)

--
Jock

Sep 29 '06 #5
Scripsit Andy Dingley:
Browsers are reliable at safely ignoring unknown attributes.
You cannot really guarantee that. The specifications impose no requirements,
and what browsers commonly do does not make them reliable; the next version
may be different.

There are at least three reasons why you cannot rely on them ignoring
unknown attributes:

1) Future specifications may add atributes, possibly with semantics
different from the meaning that you expect your nonstandard attributes to
have.

2) An "unknown" attribute might not be unknown to a browser. It might
recognize it as an extended feature, possibly in a meaning different from
yours. Different browsers may well do this differently.

3) Some browsers might actually implement the originally recommended idea,
and the "modern" XMLish idea, of reporting an error to the user when there
are syntax errors.

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

Sep 29 '06 #6

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

Similar topics

8
by: Marc Rochkind | last post by:
Nearly everything written about HTML falls into one of two categories: 1. Material written for HTML authors, or 2. Material written for user-agent implementors about standard HTML However,...
5
by: DU | last post by:
Hi! I really need to understand what is so-called browser error correction mechanisms. Can you explain this? I read somewhere (and I no longer can find where I read that) that browsers try to...
1
by: prasaddevivara | last post by:
I am using the outerHTML property to modify the HTML of existin elements in a web page in Internet Explorer. But same outerHTM property is not working in firefox browser, Anybody can tell me a...
2
by: Lau Lei Cheong | last post by:
Hello, Actually, I'm wondering if there's anything of the sort avaliable in the wild - a developer oriented W3C browser. It's kinda W3C's online validation service, just that it runs on locahost...
1
by: KPS | last post by:
I'm attempting to create a simple treeview-like behavior in JavaScript. The desired behavior happens in IE but I cannot get the same to happen in FireFox. The primary thing I want to accomplish...
7
by: jmp | last post by:
(I hope this isn't considered too far off-topic.) I work as a developer on a browser product found on handheld devices, and I'm trying to specify behavior for the browser to make it "as...
11
by: EagleRed | last post by:
I am writing an ASP.NET 2.0 application that uses master pages. I have some pages that must not be cached on the client. In ASP.NET 1.1 I achieved this using metatags: <meta...
13
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives,...
2
by: Richard Maher | last post by:
Hi, Recently on the web I came across documentation discussing Data Source Objects (DSO) in relation to browser and html functionality (in particular the ability to declare a Java applet as a...
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: 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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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.