This has to do with specifity and the use of border: 0;
. The specificity of the two sets of selectors applies border: 0;
in a different order than one another. border
is a shorthand property used to apply border-width
, border-style
and border-color
. Applying 0
or none
will remove the styles for all of those properties.
In your CodePen you have button.outline
which is playing a role in the visibility of the button's border.
Your first set is applied in this order:
button.outline
- border-style
and border-color
properties applied
[dir="ltr"] .b1
- border properties removed with border: 0;
[dir="ltr"] .b1.ouline
- border-width
applied, no color or style
Border is not visible even though there is a width because the rest of the border properties do not have values that would make it visible, like color and style.
Your second set is applied in this order:
.b2
- border properties removed with border: 0;
button.outline
- border-style
and border-color
properties applied
.b2.ouline
- border-width
applied
Border is visible because we have border properties that make it visible, i.e. width, color, style.