Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8494149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:13:14+00:00 2026-06-10T23:13:14+00:00

I have two simple css styles: div { color: white; } body { color:

  • 0

I have two simple css styles:

div
{
color: white;
}    

body
{
color: gray;
}

Each of these has a precedence value of 0,0,0,1. Therefore, according to the rules, the second style should override the first, and all text enclosed in a div should be gray instead of white. This is not what happens; the div style takes precedence no matter its position. Presumably, there’s something somewhere that says that a more specific element takes precedence over a less specific one or some such, but I can’t find anything that says so. Can anyone tell me where this behavior might be documented?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:13:16+00:00Added an answer on June 10, 2026 at 11:13 pm

    You’re correct that both rules have the same specificity – 0,0,0,1 – however they’re not targeting the div element in the same way.

    The body rule (gray text) matches the div, but only through inheritance – the div rule (white text) matches the div directly.

    When an element inherits a value from its parent, it is inheriting its computed value, and as declared in the W3C spec every element goes through a four-step calculation.

    http://www.w3.org/TR/CSS2/cascade.html#value-stages

    The final value of a property is the result of a four-step
    calculation: the value is determined through specification (the
    “specified value”), then resolved into a value that is used for
    inheritance (the “computed value”), then converted into an absolute
    value if necessary (the “used value”), and finally transformed
    according to the limitations of the local environment (the “actual
    value”).

    So on the div the color white is the only ‘specified’ value, and so takes precedence. The color gray is only a computed value, via inheritance from the body tag.

    At least, that’s how I’ve interpreted the spec.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these two simple files that define a C++ class with a tryME
I am trying to something pretty simple. I have two buttons inside a div.
I have two simple submit buttons on my form, which work just fine: <button
Let's say I have two simple models project t.string :title vote t.references :project t.integer
I have two very simple routes routes.MapRoute( post, // Route name postPage + /{slug},
I have two relatively simple codes. One main activity and one intent service. Main
I have two very simple, identical UITableViews in my app that are populated with
I have two geo-spatial simple convex polygon areas, in latitudes and longitudes (decimal degrees)
I have two functions that return simple strings. Both are registered. $.views.helpers({ parseDate: function
Question is simple: I have two List List<String> columnsOld = DBUtils.GetColumns(db, TableName); List<String> columnsNew

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.