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

ID selectors: duplicated selectors

From <URL: http://www.w3.org/TR/CSS21/selector.html#id-selectors >

I find the following text:
"What makes attributes of type ID special is that no two such attributes
can have the same value;..."

In the second example, I find the rule:

*#z98y { letter-spacing: 0.3em }

It seems to me that using the universal selector in this example is wrong,
given the text above which includes "no two such attributes can have the
same value".

Given that all of the UAs to which I have access treat all duplicated IDs
in the above example exactly the same, I was just curious about what a UA
is *supposed* to do.

Sue
Jul 20 '05 #1
11 2183
Sue Sims <su*@css.nu> wrote in news:op**************@netnews.att.net:
From <URL: http://www.w3.org/TR/CSS21/selector.html#id-selectors >

I find the following text:
"What makes attributes of type ID special is that no two such
attributes can have the same value;..."

In the second example, I find the rule:

*#z98y { letter-spacing: 0.3em }

It seems to me that using the universal selector in this example is
wrong, given the text above which includes "no two such attributes can
have the same value".


Actually, the universal selector there simply means that it doesn't matter
what element *type* has the particular ID; it could be a <p>, or a <div>,
or what have you. The selector refers to any element with that ID. The
fact that only one *element* in a document can have a particular idea
doesn't imply that only one *element type* can have it. It could be an
element of any type; there just can't be two or more such elements in the
same document.
Jul 20 '05 #2
On 17 Nov 2003 17:28:19 GMT, Eric Bohlman <eb******@earthlink.net> wrote:
Actually, the universal selector there simply means that it doesn't
matter
what element *type* has the particular ID; it could be a <p>, or a <div>,
or what have you. The selector refers to any element with that ID. The
fact that only one *element* in a document can have a particular idea
doesn't imply that only one *element type* can have it. It could be an
element of any type; there just can't be two or more such elements in the
same document.


It seemed to me that using the universal selector in that test case would
encourage re-use of the ID, which is not "allowed".

At any rate, I'm wondering whether any UA does not allow this re-use? I've
put up a TC here <URL: http://css.nu/examples/1692.html > which re-uses
the markup in the W3C example on duplicated elements, and would appreciate
input. Is this how the UA is supposed to render the markup? If so, why?

Sue "trying to clean out old bugs from the Opera bug tracking system" Sims
Jul 20 '05 #3
Sue Sims wrote:
On 17 Nov 2003 17:28:19 GMT, Eric Bohlman <eb******@earthlink.net> wrote:
Actually, the universal selector there simply means that it doesn't
matter
what element *type* has the particular ID; it could be a <p>, or a <div>,
or what have you. The selector refers to any element with that ID. The
fact that only one *element* in a document can have a particular idea
doesn't imply that only one *element type* can have it. It could be an
element of any type; there just can't be two or more such elements in the
same document.

It seemed to me that using the universal selector in that test case
would encourage re-use of the ID, which is not "allowed".

At any rate, I'm wondering whether any UA does not allow this re-use?
I've put up a TC here <URL: http://css.nu/examples/1692.html > which
re-uses the markup in the W3C example on duplicated elements, and would
appreciate input. Is this how the UA is supposed to render the markup?
If so, why?

Sue "trying to clean out old bugs from the Opera bug tracking system" Sims

An ID can also be used to be pointed at like this:

<a href="#blah">blah</a>

<h1> id="blah">blah</a>

An ID can also be used to be reached with javascript:

document.getElementById('blah').style.backgroundCo lor = "green";

Therefore it also must be unique. If you don't want all that. And just
want 2 elements be styled the same use the class attribute, which is
also allowed on almost all elements.

--
Anne van Kesteren
<http://www.annevankesteren.nl/>
Jul 20 '05 #4
On Mon, 17 Nov 2003 20:30:42 +0100, Anne van Kesteren
<ma**@annevankesteren.nl> wrote:

....<URL: http://css.nu/examples/1692.html >
....
An ID can also be used to be reached with javascript:

document.getElementById('blah').style.backgroundCo lor = "green";

Thanks! I modified the TC to include the Javascript. It works as expected
on all the browsers I tested...except that the original ID rule is still
applied to *all* of the duplicates.

I would have thought (hoped) that, like the JavaScript is *only* applied
to the first instance, the markup in the rule:

*#z98y { letter-spacing: 0.3em }

would also be applied to only the first instance.

I'm still hoping that someone can explain why is is applied to _every_
instance.

Alan? Yucca? Steve? Anyone?

Sue
Jul 20 '05 #5
Sue Sims wrote:
[snip]
I find the following text:
"What makes attributes of type ID special is that no two such attributes
can have the same value;..." [snip] Given that all of the UAs to which I have access treat all duplicated
IDs in the above example exactly the same, I was just curious about what
a UA is *supposed* to do.

Sue


Since there aren't "supposed" to be multiple elements with the same ID
in the first place, I don't think it's really meaningful to talk about
what UAs are "supposed" to do if there are - except possibly to reject
the document, but that wouldn't be very useful in the real world except
in a validating parser.

Jul 20 '05 #6
On Mon, 17 Nov 2003 21:49:19 +0000, David Leverton <u0*****@abdn.ac.uk>
wrote:

Since there aren't "supposed" to be multiple elements with the same ID
in the first place, I don't think it's really meaningful to talk about
what UAs are "supposed" to do if there are - except possibly to reject
the document, but that wouldn't be very useful in the real world except
in a validating parser.


Or as, in my specific case, trying to decide whether the behavior is a bug
or not. I would expect that an HTML parser would apply the rule to the
first instance of the ID, and show all of the other instances as the
"default". However, that is not the case, *except* in the Javascript that
I applied.

So, I'm no better off that when I asked the original question.

Sue "off to change the TC to xml" Sims
Jul 20 '05 #7
> Or as, in my specific case, trying to decide whether the behavior is
a bug
or not. I would expect that an HTML parser would apply the rule to the first instance of the ID, and show all of the other instances as the
"default".
I would expect that, unless it had some particular interest in error
reporting, an HTML parser might not even bother to check whether there
was an id had already been used and so apply the rule to all
instances. Even if it did discover a reused id I'd consider it quite
reasonable to retain it for rendering purposes. There is no correct
interpretation as the page is invalid.
However, that is not the case, *except* in the Javascript that I applied.


Apples and oranges. The CSS rule matches all the elements with that
id. The JavaScript requests just one of them then acts on that one
alone(it seems natural that the first one is returned though I could
well imagine the behaviour isn't defined for cases where there is more
than one). You haven't asked it do anything with the other ones.

Jul 20 '05 #8
On Mon, 17 Nov 2003 20:27:17 GMT, Sue Sims <su*@css.nu> wrote:
On Mon, 17 Nov 2003 20:30:42 +0100, Anne van Kesteren
<ma**@annevankesteren.nl> wrote:

...<URL: http://css.nu/examples/1692.html >
...
An ID can also be used to be reached with javascript: document.getElementById('blah').style.backgroundCo lor = "green";

Thanks! I modified the TC to include the Javascript. It works as
expected on all the browsers I tested...except that the original ID rule
is still applied to *all* of the duplicates.


Why do this testing anyway? It seems to me that you're looking for a way
to use the Id for something it was not meant to.
I would have thought (hoped) that, like the JavaScript is *only* applied
to the first instance, the markup in the rule:

*#z98y { letter-spacing: 0.3em }

would also be applied to only the first instance.
Forget it. If you want it to apply to the first instance, then let the
elements share a classname that you use to apply formatting to all the
elements, and a unique id for each of the elements that you use when
you apply formatting to that single element.
I'm still hoping that someone can explain why is is applied to _every_
instance.


Let me quote the CSS 2.1 specification which is pretty clear at this point:
<URL: http://www.w3.org/TR/CSS21/selector.html>

E#myid Matches any E element with ID equal to "myid".

--
Ole Kristian Bangås
Jul 20 '05 #9
In article <op**************@netnews.att.net> in
comp.infosystems.www.authoring.stylesheets, Sue Sims <su*@css.nu>
wrote:
*#z98y { letter-spacing: 0.3em }

It seems to me that using the universal selector in this example is wrong,
given the text above which includes "no two such attributes can have the
same value".


I'd say redundant rather than wrong. Unless I'm mistaken, that
selector is the same as "#z98y".

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #10
Stan Brown wrote:
In article <op**************@netnews.att.net> in
comp.infosystems.www.authoring.stylesheets, Sue Sims <su*@css.nu>
wrote:
*#z98y { letter-spacing: 0.3em }

It seems to me that using the universal selector in this example is wrong,
given the text above which includes "no two such attributes can have the
same value".

I'd say redundant rather than wrong. Unless I'm mistaken, that
selector is the same as "#z98y".

It is the example used by the W3C:
<http://www.w3.org/TR/CSS21/selector.html#id-selectors>. You can also
find it in the CSS3 Selectors draft.

--
Anne van Kesteren
<http://www.annevankesteren.nl/>
Jul 20 '05 #11
Stan Brown wrote:
In article <op**************@netnews.att.net> in
comp.infosystems.www.authoring.stylesheets, Sue Sims <su*@css.nu>
wrote:
*#z98y { letter-spacing: 0.3em }

It seems to me that using the universal selector in this example is wrong,
given the text above which includes "no two such attributes can have the
same value".

I'd say redundant rather than wrong. Unless I'm mistaken, that
selector is the same as "#z98y".


Unless you've defined a default namespace with the CSS3 "@namespace"
rule, in which case it only applies to elements in that namespace.

Jul 20 '05 #12

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

Similar topics

1
by: Tony Benham | last post by:
I have been getting to grips with css recently (very slowly), and one area I have a problem is when to use class selectors or id selectors. Are there any guidelines when to use each type ? The key...
18
by: news.pandora.be | last post by:
I tried everything. I even tested it in combination with opera and mozilla. (I use IE 6 mostly) It's reduced to the simple example below. Please tell me what is wrong with my understaning of...
4
by: Andy Fish | last post by:
hi, I am using descendent selectors to format cells within a table according to the css class of the table. However, when using nested tables, it seems to pick up the outer matching rule rather...
7
by: Biguana | last post by:
Hi, Apologies in advance for a newbie question, but I'm trying to decipher css stuff, I can't find a direct parallel in web tutorials, and I'm not sure what to search on. My problem is that...
6
by: Rhino | last post by:
What's the simplest way to determine which, if any, of my selectors are not needed in a given stylesheet? I have a small number of HTML pages that share two stylesheets; one stylesheet is for...
7
by: Dan | last post by:
Hi, IE 7 does not seem to like child selectors for lists. I couldn't find anything addressing this with google search. Example of problem-- If I want to apply the color red to all ordered list...
6
by: Ryan Liu | last post by:
Hi, If I have tens of thousands DataRow in a DataTable and allow the end user to pick any DataColumn(s) to check for duplicated lines, the data is so large, is there a better API, algorithm can...
7
by: John Dann | last post by:
I'm unclear as to how best to use what I'm terming the top-level CSS selectors, by which I mean selectors like *, html and body. I'm coming at this from trying to understand how best to set font...
5
by: Nathan Sokalski | last post by:
I'm not sure if this is the right place to ask this question, but I wasn't sure where else to go. I have a table made of the following tags: <table class="myclass"> <tbody> <tr><td>.</td></tr>...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.