473,806 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1937
"Bert Lancaster" <no****@yahoo.c om> 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_module s.html#s_stylem odule>
--
||| 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_module s.html#s_stylem odule>


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.c om> 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
"informativ e" 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**********@y ahoo.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**********@y ahoo.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**********@y ahoo.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 misunderstandin g 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

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

Similar topics

2
2878
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 allowed now. I have spent all day trying to figure out a solution with no luck. I have tried document.forms and various other things but havent known exactly what to do with them and couldn't get them to work. Below I will show you my current code and...
22
4767
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 "FOO" for this element (in this HTML version). The element is defined not to have this attribute. These anchors are not contained in anything. For example, the Z1
4
21306
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. http://validator.w3.org/check?uri=http://www-thaihydro.geog.cam.ac.uk/riverslice/&ss=1&verbose=1 (e.g. see line 77) suggests that it is valid, but the spec suggests that it is not. More detail:
80
6549
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 extension, where is that from? Is there a codification somewhere?
9
6050
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 value="1">test</option> </select>
16
12290
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 specification anymore, or is it an error in the SGML parser ? Any alternatives ? html code : <a href="./page.html" class="pagelink" target="_self">some text</a> used doctype :
14
4617
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 reading all of the reference document. With this is mind, I need a way to display text in a title attribute, dynamically. I don't like the idea of going through 100+ pages and making the changes every time a load new images. Is it possible to...
1
2450
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. Problem: I am teaching myself about validating for XHTML and, upon testing a page I get errors for the use of the 'name' attribute in form fields. It seems that you have to replace the 'name' attribute for the 'id' attribute.
2
4576
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) - Attribute..... is not a valid attribute of..... Validation (XHTML 1.0 Transitional) - Attribute..... is considered outdated. A newer construct is recommended. Validation (XHTML 1.0 Transitional) - Attribute values must be enclosed in quotation marks.
1
3835
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. http://emle.sourceforge.net/emle020100/lab/ng20070625_emle_lab_001-e.xml.html <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10371
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.