I want to add a top border to #childmenulist
only if .title.lengthyText
contains an element with the #highLayer
id attribute. If there is no #highLayer
id attribute, then there is no top border.
I know I can use the :has()
pseudo-class to check if #highLayer
is present or not (demonstrated in the snippet below). But say that I can’t use the :has()
pseudo-class, is there another way to write this CSS without using :has()
? Or is the other way only through JavaScript?
.title.lengthyText:has(#highLayer) #childmenuList {
border-top: 3px solid red;
}
<div class="title lengthyText">
<div class="subcontainer">
<nav id="highLayer" class="high-lay">Nav</nav>
</div>
<div id="childmenuList">child menu</div>
</div>
8