2022-07-26 11:50:43 +00:00
|
|
|
body{
|
|
|
|
font-family:Arial, Helvetica, sans-serif
|
|
|
|
}
|
|
|
|
|
2021-08-30 21:54:33 +00:00
|
|
|
.para,
|
|
|
|
.small-para {
|
2022-07-26 11:50:43 +00:00
|
|
|
color: hsl(0, 0%, 0%);
|
2022-07-29 12:18:54 +00:00
|
|
|
font-weight: 800;
|
2021-08-30 21:54:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.para {
|
|
|
|
font-size: 22px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.button {
|
2022-01-16 20:07:45 +00:00
|
|
|
background-color: rgb(255, 255, 255);
|
|
|
|
color: rgb(0, 0, 0);
|
2021-08-30 21:54:33 +00:00
|
|
|
font-size: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
div.text {
|
2022-07-26 11:50:43 +00:00
|
|
|
color: rgb(0, 0, 0);
|
|
|
|
font-weight: 200;
|
2022-01-16 20:07:45 +00:00
|
|
|
font-size: 22px;
|
2021-08-30 21:54:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SOLUTION */
|
|
|
|
|
|
|
|
/*
|
|
|
|
For the following rule, we removed it from its original position in the file:
|
|
|
|
|
|
|
|
.small-para {
|
2022-01-16 20:07:45 +00:00
|
|
|
font-size: 14px;
|
2021-08-30 21:54:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Then we placed it after the .para selector, taking advantage of the rule order since both selectors have the same specificity.
|
|
|
|
|
|
|
|
Another solution would be keeping it in its original place and just chaining selectors, giving this rule a higher specificity:
|
|
|
|
|
|
|
|
p.small-para {
|
2022-04-01 11:03:29 +00:00
|
|
|
font-size: 14px;
|
2021-08-30 21:54:33 +00:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
.small-para {
|
2022-01-16 20:07:45 +00:00
|
|
|
font-size: 14px;
|
2022-07-29 12:18:54 +00:00
|
|
|
font-weight: 800;
|
2021-08-30 21:54:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
For the following rule we removed the original .confirm selector:
|
|
|
|
|
|
|
|
.confirm {
|
|
|
|
background: green;
|
|
|
|
color: white;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
Then we used an ID selector instead, since it has a higher specificity than the .button selector.
|
|
|
|
|
|
|
|
Other solutions would be to simply move the .confirm rule below the .button rule, or to use the .button.confirm selector without moving it:
|
|
|
|
|
|
|
|
.button.confirm {
|
|
|
|
background: green;
|
|
|
|
color: white;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#confirm-button {
|
|
|
|
background: green;
|
|
|
|
color: white;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
For the following rule we first removed it from its original position in the file:
|
|
|
|
|
|
|
|
.child {
|
|
|
|
color: red;
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
|
2022-04-01 11:03:29 +00:00
|
|
|
Then we added another selector to create a descendant combinator. If we only created a descendant combinator, the specificity would be tied with the
|
|
|
|
div.text selector and it would come down to rule order, and if we only moved it the div.text selector would still have a higher specificity.
|
2021-08-30 21:54:33 +00:00
|
|
|
|
|
|
|
Another solution would be to keep the rule where it was and just replace the div selector with the .text selector:
|
|
|
|
|
|
|
|
.text .child {
|
|
|
|
color: red;
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
div .child {
|
2022-07-26 11:50:43 +00:00
|
|
|
color: rgb(0, 0, 0);
|
2022-07-29 12:18:54 +00:00
|
|
|
font-weight: 800;
|
2021-08-30 21:54:33 +00:00
|
|
|
font-size: 14px;
|
2022-01-16 20:07:45 +00:00
|
|
|
}
|