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

universal selector specificity

I have this simple div with a label in:

Expand|Select|Wrap|Line Numbers
  1. <div id="TestDiv">
  2.     <label>TEST CSS</label> 
  3. </div> 
I am applying the following CSS:

Expand|Select|Wrap|Line Numbers
  1. div#TestDiv *
  2.  
  3.   color:Blue;
  4. }
  5.  
  6. div#TestDiv 
  7. {
  8.  color:Red;
Now as I understand it the universal selector has a specificity of 0,0,0,0, so this means that both of these items have the same specificity. Therefore I would expect the label to be red as that comes afterwards in the stylesheet. So why is the label shown as blue for me?
Mar 21 '08 #1
1 1562
drhowarddrfine
7,435 Expert 4TB
Because the universal selector is all things within the div while the second is specific to the div only.
Mar 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Laurence Tureaud | last post by:
hello i'm just getting started with CSS & am reading through Eric Meyer on CSS, specifically the first chapter. he creates these styles: td#advert {stuff} #content-top td { stuff } tr...
5
by: Harlan Messinger | last post by:
If I want to give special priority to property values I want to declare for a particular class, should .myclass.myclass.myclass.myclass.myclass.myclass.myclass.myclass.myclass { /* declarations...
11
by: Vladimir | last post by:
Hello! I'd like to select one of possible entities according to a given index: select(index, A, B) would return A if index is 0, B if index is (or greater than) 1. so i write:
6
by: martin.eyles | last post by:
I am having a problem with this page:- http://www.bytronic.com/tests/centre.html I want a nice centred paragraph, but get a justified paragraph. I expected the .centre to override the #content...
5
by: Gerry Vandermaesen | last post by:
Hi, I'm trying out the following: CSS .className { width: 30px; height: 30px; border: 1px solid black; }
5
by: Jim Garrison | last post by:
In reading someone else's stylesheet I ran across the following two selectors, in the following order. #footer .label { ... } #footer .label { ... } Are these not identical in effect? If...
8
by: sajid | last post by:
The CSS 2.1 Specification describes how to sort a list of selectors in order of specificity, but it doesn't provide a method to calculate the specificity of a single selector in isolation. I've...
1
by: jorgedec | last post by:
I have two test vertical menus. If I apply a border-bottom using a selecter of div.vbar a It looks fine. If I apply the border-bottom using a selecter of div.vbar ul li a
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: 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: 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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.