Why are there two colons here? span::before

It’s a pseudo-element, as defined by the CSS Selectors Level 3 spec: The ::before and ::after pseudo-elements can be used to describe generated content before or after an element’s content. It is effectively the same as the single-colon syntax defined by the level 2 spec. The level 3 spec introduces an extra colon to differentiate … Read more

Select odd even child excluding the hidden child

:nth-child() pseudo-class looks through the children tree of the parent to match the valid child (odd, even, etc), therefore when you combine it with :not(.hidden) it won’t filter the elements properly. Alternatively, we could fake the effect by CSS gradient as follows: .hidden {display:none;} .wrap { line-height: 1.2em; background-color: orange; background-image: linear-gradient(transparent 50%, green 50%); … Read more

Why CSS selector with > sign (direct child) overrides default styles?

The issue is not the child combinator (>), it’s the color property, which is inheritable. Although the initial value of the color property varies from browser to browser, inherit is common. This means that an element’s text color is inherited from the parent. You’re seeing this in your code. In contrast, the border property is … Read more

::slotted CSS selector for nested children in shadowDOM slot [duplicate]

styling ::slotted elements in shadowDOM TL;DR ::slotted Specs: https://drafts.csswg.org/css-scoping/#slotted-pseudo slotted content remains in light DOM, is reflected to a <slot> in shadow DOM ::slotted(x) targets the lightDOM outer-Element (aka ‘skin’), NOT the SLOT in shadowDOM ::slotted(x) takes basic selectors Inheritable styles trickle into shadowDOM https://lamplightdev.com/blog/2019/03/26/why-is-my-web-component-inheriting-styles/ For the latest WHATWG discussion on SLOT and related topics, … Read more

How do I prevent my style from being overridden another style on a surrounding div?

You can throw the !important attribute on h3#issueHeader to force the browser to use that style h3#issueHeader { color: blue !important; } However, it is only partially supported in IE6 Additionally, this should only be used as a last resort to the other solutions purposed. This is because if users of your website want to … Read more

does the order of styles matter?

If the rules are equal in specificity (in this case they are), individual rules get overridden in the order they’re defined in the CSS, so in your example red wins because it comes later in the CSS definitions. The same rule applies in other cases as well, for example: <div class=”red green”> Which of these … Read more