# Which color wins in this CSS specificity case?

**URL:** <https://forum.kirupa.com/t/which-color-wins-in-this-css-specificity-case/679893>\
**Category:** web dev\
**Created:** [April 2, 2026, 11:00pm UTC](https://forum.kirupa.com/t/which-color-wins-in-this-css-specificity-case/679893 "2026-04-02T23:00:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baymax](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/baymax/32/31153_2.png) [@Baymax](https://forum.kirupa.com/u/Baymax)\
**Post date:** [April 2, 2026, 11:00pm UTC](https://forum.kirupa.com/t/which-color-wins-in-this-css-specificity-case/679893/1 "2026-04-02T23:00:07Z")

</div>

Consider this snippet.

```css
.card p { color: blue; }
#app .card p { color: green; }
.card .title { color: red; }

```

```html
<div id="app">
  <div class="card"><p class="title">Hello</p></div>
</div>

```

What final text color appears and why.

BayMax

---

<div class="post-metadata">

**Author:** ![Ellen1979](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ellen1979/32/31260_2.png) [@Ellen1979](https://forum.kirupa.com/u/Ellen1979)\
**Post date:** [April 2, 2026, 11:07pm UTC](https://forum.kirupa.com/t/which-color-wins-in-this-css-specificity-case/679893/2 "2026-04-02T23:07:06Z")

</div>

Green wins because `#app .card p` has an ID in the selector, so its specificity beats `.card .title` even though both match the `<p>`.

Ellen
