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

Simple selector question

In reading someone else's stylesheet I ran across the following
two selectors, in the following order.

#footer .label { ... }

[id]#footer .label { ... }
Are these not identical in effect? If not, I'm missing something
about attribute selectors. My reasoning is that in the second selector
[id] is redundant, since anything matching #footer MUST have an id
attribute. (There was no space between the [id] and the #footer).

I looked in the W3C 2.1 spec, and the only thing I could find is that
the second selector has a slightly higher specificity because of the
explicit [id], so it will ALWAYS take precedence over the first rule.

Is this correct?

TIA

Jim Garrison
jhg at acm dot org
Apr 24 '06 #1
5 1332
Jim Garrison wrote:

I looked in the W3C 2.1 spec, and the only thing I could find is that
the second selector has a slightly higher specificity because of the
explicit [id], so it will ALWAYS take precedence over the first rule.

Is this correct?

All other things being equal, yes.
The ruleset with the greatest specificity wins.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Apr 24 '06 #2
Jim Garrison wrote:
In reading someone else's stylesheet I ran across the following
two selectors, in the following order.

#footer .label { ... }

[id]#footer .label { ... }


Internet Explorer does not support attribute selectors. This could be being
used as a technique to apply additional styles only to MSIE.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Apr 24 '06 #3
David Dorward wrote:
Jim Garrison wrote:
In reading someone else's stylesheet I ran across the following
two selectors, in the following order.

#footer .label { ... }

[id]#footer .label { ... }


Internet Explorer does not support attribute selectors. This could be being
used as a technique to apply additional styles only to MSIE.


Are you saying that the first selector would be used by MSIE, but the
second one would apply in browsers that support attribute selectors?
Apr 24 '06 #4
On Mon, 24 Apr 2006, Jim Garrison wrote:
David Dorward wrote:
Jim Garrison wrote:
In reading someone else's stylesheet I ran across the following
two selectors, in the following order.

#footer .label { ... }

[id]#footer .label { ... }


Internet Explorer does not support attribute selectors. This could
be being used as a technique to apply additional styles only to
MSIE.


Are you saying that the first selector would be used by MSIE, but the
second one would apply in browsers that support attribute selectors?


*Both* of them would apply in supporting browsers, but in the
case of a clash in values, the second one (having higher priority)
would win.
Apr 24 '06 #5
Alan J. Flavell wrote:
On Mon, 24 Apr 2006, Jim Garrison wrote:
David Dorward wrote:
Jim Garrison wrote:
> In reading someone else's stylesheet I ran across the following
> two selectors, in the following order.
>
> #footer .label { ... }
>
> [id]#footer .label { ... }

Internet Explorer does not support attribute selectors. This could
be being used as a technique to apply additional styles only to
MSIE.


Are you saying that the first selector would be used by MSIE, but the
second one would apply in browsers that support attribute selectors?


*Both* of them would apply in supporting browsers, but in the
case of a clash in values, the second one (having higher priority)
would win.


It's a less-robust method of achieving the same end as conditional
comments, although with the negligible advantage of only needing one
stylesheet.
--
AGw.

Apr 24 '06 #6

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

Similar topics

8
by: Steve K | last post by:
I have a table with 61 rows and 4 columns. Names, email, phone, affiliation. I want to have a solid 1px bottom border for each row. But I am not smart enough with CSS to figure out how to do...
2
by: Andrew Poulos | last post by:
If I have some HTML that looks like this: <div class="option"> <table> <tbody> <tr> <td>blah</td> <td>blah</td> </tr> </tbody>
3
by: | last post by:
Hi there, I'm relatively new to CSS and having a difficult time with something that should be simple. I've searched this group for answers to this problem, but am afraid I haven't been able to...
7
by: Megan | last post by:
Hi everybody- I inherited a database that somehow uses a bound combo box as a record selector. Let me give you some background. The form is based on data from 2 tables. The first table, Person,...
14
by: Melanie Avids | last post by:
Hi, I'm tired of banging my head on the computer. I'm hoping someone can help? I have a very small simple page that looks perfect in Firefox, Safari, and Netscape. It's clean. The HTML and CSS both...
2
by: olivier_henley | last post by:
hi to all, let say I have a html div which id is 'mydiv'. In the style, I change the #mydiv properties dynamically. After those changes have been made, I would like to keep them intact but...
0
by: DBC User | last post by:
Hi, I have a datagridview, with column header and on the lefthandside the rowselector. I would like to do the following 2 1. When the user click ONLY the row selector or inside the gridview...
2
by: smachin1000 | last post by:
Hi All, In the sample schema & document below, I'd like the attribute "name" to be unique for all function elements under function_list. The tools I'm using (XML Spy and xmllint) all validate...
6
by: _googlepost | last post by:
I have some CSS that goes something like this: table.TableStyle {font-family: "Helvetica", "Ariel"; background- color:white; border-collapse:collapse;} table.TableStyle COLGROUP { background-...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...
0
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...

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.