Skip to main content

The :has() pseudo-class (a.k.a. the parent selector)

  • January 26, 2026
  • 7 replies
  • 104 views

Ian
Guide II

So, this has been around for a few years now, but I only recently became aware of it. And I thought I’d spread the word here, because it’s really quite cool and opens up more options for us using custom CSS in Docebo.

There’s a lot you can read about this online, but I liked this little run-down: https://gomakethings.com/the-has-css-pseudo-class/

A couple of examples where I’ve already found a use-case for this in Docebo:

  • It bugs me that when you self-enroll in a course that requires admin approval, on the course page it shows your status as “Enrolled” with a warning box below that. As far as I’m concerned, no. You are not enrolled yet. But how do I hide that status in this situation without hiding it all the time?
    Answer:
.lrn-widget-content-enrollment-status:has(+.lrn-widget-content-enrollment-description) {
display: none;
}
  • I have an external page embedded as an iframe. I don’t want the title bar to show up for this particular page; it’s superfluous and unhelpful. Perhaps there’s another way to do this, but this is what worked for me:
doc-layout-title-bar:has(+ div #doc-page-123) {
display: none;
}

So actually, both of these examples are more like “previous sibling” selectors rather than “parent” selectors. But the point stands.

Is anyone else using the :has() pseudo-class? And if so:

 

7 replies

TaiSaxty
Helper I
Forum|alt.badge.img
  • Helper I
  • February 23, 2026

For those trying to follow this and re-use it, it can be quite hard to find the page number you are looking for. If you are using the developer tools (F12) to find it this is how to locate it (please let me know if there is an easier way)

On the page where you want to hide the title bar, press F12 to open the Developer tools
Click on the Elements tab
Open up the Body string
open up the next 3 div string
look for the Doc Layout string
open the next div string
open up the main id string
open up the Div id=”doc-layout_page_content” string
Look for the string that reads: ng-component _xyzBlahBlahBlah is=”doc-page-16 ← This is your page reference you need for your CSS.

You then add this in to your CSS:

/*Hide title bar on homepage*/

doc-layout-title-bar:has(+ div #doc-page-16) {

    display:none;

}

(please make sure its the relevant page number on your Docebo LMS, page 16 is the one on my sandbox I’m using to give you this example.

I hope this helps!


dklinger
Hero III
Forum|alt.badge.img+11
  • Hero III
  • February 23, 2026

I am going to show my age - but it was so nice when pseudo-classes became part of the excepted css standards and not browser specific anymore. Ok - I have been doing this too long….🙄 


Ian
Guide II
  • Author
  • Guide II
  • February 26, 2026

There is an easier way to get the page number, ​@TaiSaxty: it’s part of the page URL.

https://example.com/pages/123/slug

Built-in pages are an exception. You can still get their IDs from the URL when you try to edit them via Manage Pages:

https://example.com/pages/page-management/settings/12;panel=1

But the problem is that their HTML is a bit different. For example, in my sandbox at least, Page 12 is “My Team”, but you’d need to use mng-my-team in place of #doc-page-12:

doc-layout-title-bar:has(+ div mng-my-team) {
display: none;
}

That said, I’m not sure it makes sense to hide the title bar for the built-in pages.


TaiSaxty
Helper I
Forum|alt.badge.img
  • Helper I
  • February 27, 2026

Thanks ​@Ian 

I was showing a colleague yesterday when I noticed it in the url. My brain was obviously not braining. This said we do have customers that really do not want it so we’re trying to hide all banners that do t have new buttons embedded into them.

 

do you know what’s the correct one for the myActivities page?


Ian
Guide II
  • Author
  • Guide II
  • February 27, 2026

No problem, ​@TaiSaxty! I should, by the way, have given you credit for the instructions on the browser dev tools, because that is the approach one needs in general when trying to figure out exceptions like this, just inspecting the page structure.

It turns out that My Activities is, for some weird reason, using an iframe. You can isolate it using an attribute selector:

doc-layout-title-bar:has(+ div iframe[src="lms/index.php?r=myActivities/index"]) {
display: none;
}

Hope this helps!


TaiSaxty
Helper I
Forum|alt.badge.img
  • Helper I
  • February 27, 2026

No worries and thank you ​@Ian im putting together a collection of CSS used over the years so as a team we can refer back to it for further customers etc, and as I don’t come from a world using CSS, im trying to learn what I can on the go. Thank you for finding me the tag for this. I’ll give it a go on Monday! 


TaiSaxty
Helper I
Forum|alt.badge.img
  • Helper I
  • March 3, 2026

The above worked like a charm, thanks ​@Ian