473,382 Members | 1,424 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,382 software developers and data experts.

ID attribute in XHTML 1.1

I'm not actually using it on the web but can anyone tell me why the ID
attribute on a <style> tag causes an error in the W3C validator for an
XHTML 1.1 document? It doesn't have a problem for a XHTML 1.0 or HTML
document.

I was just playing around with some test code that contained an embedded
stylesheet and used <?xml-stylesheet type="text/css" href="#styles"?>
before the DOCTYPE (which I think is what you're technically supposed to
do with XML) but using <style type="text/css" id="styles"> causes the
error - only if I use an XHTML 1.1 doctype.

For real pages I use HTML 4, I was just playing around in XHTML 1.1 to see
what browsers did with it, and if it validated or not and am curious why
ID is not allowed on all tags.
May 18 '06 #1
19 1895
"Bert Lancaster" <no****@yahoo.com> writes:
I'm not actually using it on the web but can anyone tell me why the ID
attribute on a <style> tag causes an error in the W3C validator for an
XHTML 1.1 document? It doesn't have a problem for a XHTML 1.0 or HTML
document.


I suppose it would have been too much hassle to consult the
documentation?

<http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_stylemodule>
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
May 18 '06 #2
On Thu, 18 May 2006 10:45:00 +0100, Eric B. Bednarz
<be*****@fahr-zur-hoelle.org> wrote:
I suppose it would have been too much hassle to consult the
documentation?

<http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_stylemodule>


And what makes you suppose that I haven't already, hm? But thanks for the
link to what I was looking for last night.

So, the ID attribute isn't allowed on <style> tags in XHTML 1.1. Can
anyone else tell me why this was changed from XHTML 1.0 and what should be
done strictly speaking since using an ID is what's recommended for
documents sent as XML according to this:
<http://www.w3.org/TR/xhtml1/#C_14>
May 18 '06 #3
Bert Lancaster <no****@yahoo.com> scripsit:
So, the ID attribute isn't allowed on <style> tags in XHTML 1.1.
Yes, this is one of the silent changes that you need to find out from the
formalized syntax, i.e. DTD.
Can anyone else tell me why this was changed from XHTML 1.0
The authors of XHTML 1.1 didn't bother _mentioning_ the change in the
"informative" annex purported to document the changes,
http://www.w3.org/TR/xhtml11/changes.html#a_changes
So I think it's unrealistic to expect them to _explain_ their reasons.

This particular change does not sound very important, though. Where would
you need the id attribute for a <style> element? It's not useful in linking,
and it's not useful in writing stylesheets. It could perhaps be used in
client-side scripting, called "DHTML" or "Ajax" depending on the vintage of
marketese. However, I would expect you to be interested in manipulating CSS
rules rather than the elements where they appear in XHTML source.
and what
should be done strictly speaking since using an ID is what's
recommended for documents sent as XML according to this:
<http://www.w3.org/TR/xhtml1/#C_14>


In the light of that recommendation, the change looks rather odd indeed. On
the other hand, you can circumvent the problem by making your style sheet(s)
external, i.e. by not using the <style> element.

Perhaps they though that XHTML 1.1 documents should not be served as XML?

May 18 '06 #4
Jukka K. Korpela wrote:

Perhaps they though that XHTML 1.1 documents should not be served as
XML?


Ha! I think that remark was meant to be sarcastic, but perhaps it is
simply crazy but true.

"Irony is a form of utterance that postulates a double audience,
consisting of one party that hearing shall hear and shall not
understand, and another party that, when more is meant than meets the
ear, is aware, both of that “more” and of the outsider’s
incomprehension."
~~ H.W.Fowler
--
Jack.
May 18 '06 #5
VK

Bert Lancaster wrote:
using <style type="text/css" id="styles"> causes the
error - only if I use an XHTML 1.1 doctype.


<style> element never had ID attribute, even in HTML 4.01 Transitional.
You must be confused it with external stylesheets via <link
rel="stylesheet> where ID is always welcome.

I don't know why wouldn't it cause validation error in any HTML/XHTML
before 1.1 Must be a validator bug they finally fixed. See more at:
<http://www.w3.org/TR/html401/loose.dtd> and
<http://www.w3.org/TR/html401/strict.dtd>

May 18 '06 #6
On Thu, 18 May 2006 15:15:06 +0100, VK <sc**********@yahoo.com> wrote:
You must be confused it with external stylesheets via <link
rel="stylesheet> where ID is always welcome.
No, I meant it as I explained:
<http://www.w3.org/TR/xhtml1/#C_14>

It seems despite the length of time various W3C recommendations have taken
to complete, there's some contradiction on this issue. So, is there a
definitive answer to whether embedded stylesheets on XHTML served as XML
should have an ID that's linked to before the DOCTYPE (as is done with
external stylesheets) or not?

If they shouldn't then what's the W3C's rationale for explicitly telling
people to do this just?! Was it meant to be something that *should* be
done or just a hack to work around practical problems of some kind in XML
agents of the day? (Much like the recommended practice of leaving a space
before the closing slash of a shorthand tag, etc.)

I'm not very good with DTDs but doesn't the following snippet from the
XHTML 1.0 Strict DTD mean that ID is an allowed attribute for the <style>
tag?

<!-- style info, which may include CDATA sections -->
<!ELEMENT style (#PCDATA)>
<!ATTLIST style
%i18n;
id ID #IMPLIED
type %ContentType; #REQUIRED
media %MediaDesc; #IMPLIED
title %Text; #IMPLIED
xml:space (preserve) #FIXED 'preserve'


If so, is it possible that the modularisation of XHTML in 1.1 is somehow
responsible for ID no longer being valid, and that this isn't what the W3C
meant to happen?
On a largely unrelated topic, if an XHTML 1.0 Strict document is sent as
application/xhtml+xml, is there any reason to comment-out CDATA markers in
<script> and <style> elements? Eg:

<script type="text/javascript">
// <![CDATA[
alert('hello world')
// ]]>
</script>

<style type="text/css">
/* <![CDATA[ */
selector {property:value}
/* ]]> */
</style>

The W3C guidelines recommend using <![CDATA[ ]]> around the contents of
embedded scripts and stylesheets but their example[1] doesn't show any
commenting out, yet I've seen this being used in pages before.

I can understand using HTML comments to hide embedded scripts and
stylesheets in HTML documents from ancient browsers, but given that old
browsers (including MSIE7) are not capable of displaying XHTML documents
sent like this (where the contents of these elements really will be
treated as PCDATA) I can't see a need to comment-out the CDATA markers. Is
there any point in doing so? The nearest reason I can think of is if
you're going to serve such documents as text/html or want to open them
direct from disk, where the browser may process it as HTML rather than XML
and think that the CDATA markers are broken code in your Javascript, but
I'm talking about in theory where they'd only ever be served as proper
XHTML to all browsers.

[1] <http://www.w3.org/TR/xhtml1/#h-4.8>
May 18 '06 #7
VK wrote:
<style> element never had ID attribute, even in HTML 4.01 Transitional.


<style> gained an id attribute in XHTML 1.0 (Strict and Transitional)
and lost it for XHTML 1.1
For someone who's so adamant about always downloading DTDs, it's
surprising that you didn;t actually check this before posting.

I don't know why an element gained an attribute in moving from HTML to
XML, as XHTML 1.0 was always intended to be a simple transcoding, not a
functional alteration. Nor do I know why the attribute was dropped
later. Perhaps it was a mistake in the first place, then corrected.

May 18 '06 #8
VK

Bert Lancaster wrote:
On Thu, 18 May 2006 15:15:06 +0100, VK <sc**********@yahoo.com> wrote:
You must be confused it with external stylesheets via <link
rel="stylesheet> where ID is always welcome.


No, I meant it as I explained:
<http://www.w3.org/TR/xhtml1/#C_14>


Oh, that one... Plain b.s. - just did not add it yet to the errata
section. <style> element doesn't have and never had ID attribute, and
validator will show the error "there is no attribute "ID" either it's
HTML or XHTML. Must be one of "invited experts" wrote this. Sometimes I
wonder where do they invite some experts from? Some look like invited
from the closest campus bar :-)

May 18 '06 #9
On Thu, 18 May 2006 16:37:25 +0100, VK <sc**********@yahoo.com> wrote:
<http://www.w3.org/TR/xhtml1/#C_14>
Oh, that one... Plain b.s.


No, plain W3C recommendation! I can't just ignore it as if it's a mistake
because this is an official spec that went through draft, CR and last call
stages before being released, not a third party tutorial or primer that is
subject to interpretation or misunderstanding by its author (or so you'd
think). I'm not arguing in favour of it (or against it come to that), I'm
just trying to get to the bottom of some conflicting statements by the W3C.

<style> element doesn't have and never had ID attribute
validator will show the error "there is no attribute "ID" either it's
HTML or XHTML.


But I just posted the excerpt from the DTD showing you that ID *is* a
valid attribute in XHTML 1.0, and I previously said the validator passes
it for 1.0 documents but not 1.1. If it only appeared in the 1.0 DTD then
I could imagine it being a simple mistake, but the fact that they've used
that attribute in example code they're recommending everyone else uses
suggests otherwise. But then it gets dropped again in the very next spec
they release and they publish no guidelines updating their previous advice
which relies on that attribute...
May 18 '06 #10
VK

Andy Dingley <di*****@codesmiths.com> wrote:
For someone who's so adamant about always downloading DTDs, it's
surprising that you didn;t actually check this before posting.


"Adamant"? I always was highly sceptical about these DTD games and
about XHTML as such - you may track my posts in c.l.j. as far as you
want. Yet I was forcely involved in some DOCTYPE/DTD discussions and
the major discover was that many DTD-fighters actually never looked in
what the hell they were linking and promoting for so long.

1) "In the name of Our Lord"

2) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

Amin! :-))

And yes: I checked <http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
and indeed they put ID in XHTML 1.0 in every single element, including
even <html>, <script> and <style>

I presume it is connected with the initial attempt to represent XHTML
as fully XML-conformant (and any XML element may have ID). In this
aspect it is interesting to compare XHTML 1.0 vs XHTML 1.1 DTD changes
and the XHTML definition itself.

While XHTML 1.0 is "XML based" and "XML conforming":
<http://www.w3.org/TR/xhtml1/#xhtml>,
XHTML 1.1 doesn't have any strict definitions or references at all. It
only says how good and cool XHTML 1.1 is :
<http://www.w3.org/TR/xhtml11/>

Only somewhere between the lines it's /mumbled/ ;-) that it's SGML
based - which is as broad as to say that "XHTML is some kind of markup
system".

May 18 '06 #11
VK wrote:

I presume it is connected with the initial attempt to represent XHTML
as fully XML-conformant (and any XML element may have ID).


Well, *that's* rubbish. If an XML document has a DTD, then its elements
can only have id attributes if that is permitted by the DTD. Obviously.
And indeed, XHTML *does* have a DTD.

--
Jack.
May 18 '06 #12
VK

Jack wrote:
VK wrote:

I presume it is connected with the initial attempt to represent XHTML
as fully XML-conformant (and any XML element may have ID).


Well, *that's* rubbish. If an XML document has a DTD, then its elements
can only have id attributes if that is permitted by the DTD. Obviously.
And indeed, XHTML *does* have a DTD.


It is possibly rubbish. Just a strange thing I noticed is that in any
XML-based namespase from Mozilla ID's are explicetly allowed to /every
single element/, even if there is no technical means to ever use them.
I met this originally in XBL, and the same story seems for XUL.
Something like "are you XML-based? Then get an ID no matter what".
Maybe it's just a side effect of something I have no clue about: yet
seems like "strict XML-conformance" and ID attribute go somehow
together for W3C and Mozilla respectively.

May 18 '06 #13
VK

VK wrote:
Maybe it's just a side effect of something I have no clue about: yet
seems like "strict XML-conformance" and ID attribute go somehow
together for W3C and Mozilla respectively.


Yup.

XHTML 1.0 : "XML-based", "XML-conformant" by W3C
<html>, <script>, <style> got ID attributes they never had before.
Respectively say <html id="foobar"...> in HTML 1.0 validates just fine.

XHTML 1.1 : no mention of conformance except a foggy "SGML rules"
mention.
<html>, <script>, <style> lost ID attributes again. Respectively say
<html id="foobar"...> in HTML 1.1 gives an error "there is not
attribute ID". We know the identical result for <style> and I guess
there is no use to check for <script> - though anyone is welcome.

There must be some XML specs the whole world reads in the "wrong" way
(thus not in the way W3C meant).

Again a good question to the "decryption group" at <comp.text.xml>

May 18 '06 #14
VK wrote:
Jack wrote:
VK wrote:
I presume it is connected with the initial attempt to represent XHTML
as fully XML-conformant (and any XML element may have ID).

Well, *that's* rubbish. If an XML document has a DTD, then its elements
can only have id attributes if that is permitted by the DTD. Obviously.
And indeed, XHTML *does* have a DTD.


It is possibly rubbish. Just a strange thing I noticed is that in any
XML-based namespase from Mozilla ID's are explicetly allowed to /every
single element/, even if there is no technical means to ever use them.
I met this originally in XBL, and the same story seems for XUL.
Something like "are you XML-based? Then get an ID no matter what".
Maybe it's just a side effect of something I have no clue about: yet
seems like "strict XML-conformance" and ID attribute go somehow
together for W3C and Mozilla respectively.


Maybe there are SGML-based languages that require end tags for all
elements. It doesn't following that SGML requires end tags.
May 18 '06 #15
Bert Lancaster wrote:
I was just playing around with some test code that contained an embedded
stylesheet and used <?xml-stylesheet type="text/css" href="#styles"?>
before the DOCTYPE (which I think is what you're technically supposed to
do with XML)
It's certainly a good idea as it allows your page to be displayed
correctly by XML user-agents even if they have no innate knowledge of
XHTML.
but using <style type="text/css" id="styles"> causes the error - only
if I use an XHTML 1.1 doctype.


XHTML 1.1 removed the id attribute from the style element. This was a
pretty dumb thing to do IMHO.

Stick with 1.0.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

May 20 '06 #16
Jukka K. Korpela wrote:
This particular change does not sound very important, though. Where would
you need the id attribute for a <style> element?


Because generic XML agents, with no innate knowledge of XHTML, will
not know to read CSS styling information from the <style> element unless
told to with an <?xml-stylesheet ... ?> processing instruction. The PI
needs a URL to link to, hence the need for an id on the <style> element.

Yes, this does effect real life browsers -- some of the Opera 6.x series
had very little XHTML knowledge and just used a generic XML
parser/renderer (unless the XHTML was served as text/html). They required
that stylesheets were linked to with processing instructions, and didn't
recognise any external entities.

Of course the solution is to move styling info entirely into external
style sheets, which is generally good practice anyway.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

May 20 '06 #17
In article <79************@ophelia.g5n.co.uk>,
Toby Inkster <us**********@tobyinkster.co.uk> wrote:
Jukka K. Korpela wrote:
This particular change does not sound very important, though. Where would
you need the id attribute for a <style> element?

It is just easier if all elements can have an id instead of someone
trying to guess which ones never need it.
Because generic XML agents, with no innate knowledge of XHTML, will
not know to read CSS styling information from the <style> element unless
told to with an <?xml-stylesheet ... ?> processing instruction. The PI
needs a URL to link to, hence the need for an id on the <style> element.
Do you have evidence of UAs that:
1) Don't know about XHTML but know about XML and CSS
AND
2) Know about the IDness of id on XHTML elements
AND
3) Support same-document fragment identifier references in the
xml-stylesheet PI
?
Yes, this does effect real life browsers -- some of the Opera 6.x series
had very little XHTML knowledge and just used a generic XML
parser/renderer (unless the XHTML was served as text/html). They required
that stylesheets were linked to with processing instructions, and didn't
recognise any external entities.


And did the fragment identifier reference work?

--
Henri Sivonen
hs******@iki.fi
http://hsivonen.iki.fi/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
May 20 '06 #18
Henri Sivonen wrote:
And did the fragment identifier reference work?


Yep.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

May 20 '06 #19
"Bert Lancaster" <no****@yahoo.com> writes:
Eric B. Bednarz <be*****@fahr-zur-hoelle.org> wrote:
I suppose it would have been too much hassle to consult the
documentation?

<http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_stylemodule>
And what makes you suppose that I haven't already, hm?


You asked *why* the W3C validator throws an error; for XHTML 1.1 I
didn't know the answer myself offhand and looked it up (that's the
obvious course of action, if something is not valid it is probably not
declared, but there was no test case attached, you *could* just have
done something goofy, after all).
So, the ID attribute isn't allowed on <style> tags in XHTML 1.1.
Better make that 'elements' (e.g. attributes are never allowed on end
*tags* of any element type ;-).
Can anyone else tell me why this was changed from XHTML 1.0


As it isn't documented (as Jukka pointed out, and that was the second
location I looked at) you'd be better off to ask that on the applicable
W3C working group mailing list.
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
May 22 '06 #20

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

Similar topics

2
by: piraticman | last post by:
Hi. I have some code for a javascript jump menu... It validated with HTML 4.0 but now does not validate with XHTML strict 1.0. I have used name atributes in my code which aparantly are not...
22
by: Haines Brown | last post by:
I have a document with a set of internal links such as: <a name="Z1"></a>... <a name="Z2"></a>... The W3C validator objects to the first instance of the name attribute: There is no attribute...
4
by: Martin Lucas-Smith | last post by:
I am wanting to know whether are XHTML1-valid characters for use within an id attribute and/or a name attribute. ...
80
by: Neal | last post by:
Been searching around, and found http://www.w3.org/WAI/ER/IG/ert/iso639.htm which is great, as I've been looking for a guide to what codes are acceptable. I see stuff like lang="en-us" - that...
9
by: aragon | last post by:
Hi all, is it legal to use a fully-numeric string as "name" attribute for the <select> tag in the XHTML standard? E.g.: <form action="action.php" method="get"> <select name="12345"> <option...
16
by: Mark van Ballegooijen | last post by:
When using the XHTML 1.0 validator at http://validator.w3.org/check, an error will be raised for every instance of a "target" attribute in "A" elements. Is it truely because it is not part of this...
14
by: Del Ferguson | last post by:
Group, New to this list. I just found out that FireFox does not display the img alt attribute the same way IE does. I use both browsers to verify that my pages are readable. Dumb me for not...
1
by: Simon Barnett | last post by:
Hi, RE: Converting pages including ASP pages for XHTML My question relates to ASP not ASP.NET - I can't find a newsgroup for ASP and hoped it was still relevant in ASP.NET - sorry if it's not....
2
by: Radu | last post by:
Hi. I have been working at home on a web project (VSNET 2005 SP1). Now I have brought the project at work, and I suddenly have plenty of warnings like: Validation (XHTML 1.0 Transitional) -...
1
by: C.W.Holeman II | last post by:
I have an xmlns attribute that produces an XHTML validation error and I do not understand why it is considered an error.The file displays as expected on Firefox and IE7. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.