I've got a left-hand border on items in a list, and for all of them I set the border-left-color
to transparent. The active item, denoted by a css class "active day" gets an actual color to its border. The code looks something like this (note I've omitted irrelevant styles):
<!-- example.html -->
<div id="day-sidebar">
<div class="active-day">
<h2>19</h2>
<p>Fri</p>
</div>
<div>
<h2>20</h2>
<p>Sat</p>
</div>
<div>
<h2>21</h2>
<p>Sun</p>
</div>
</div>
/* example.css */
#day-sidebar div {
border-left-width: 15px;
border-left-style: solid;
border-left-color: transparent;
}
.active-day {
border-left-color: red;
}
My understanding is:
- Classes take higher precedence than tags
- Within a CSS file, rules later in the file take precedence to rules earlier in the file
Yet my first div
in this example does not take on the new border color for active-day
. Why is this?
Note: It works when I add !important
to the CSS, but I understand that should only be used as a final measure.