Is there a way to target the first occurrence of the highest heading element (h*
) in a DOM structure?
Perhaps something along the lines of
(h1, h2, h3, h4, h5, h6):first-of-ordered-set
For example, if the DOM contains h2
, h3
, h1
, h2
, h1
, it should select the first h1
;
and if there is h3
, h3
, h2
, h2
, h4
, it should pick the first h2
.
Assuming that the h*
elements are not nested.
Do you think CSS has this capability?
Here's a resource that might be helpful: https://css-tricks.com/extremely-handy-nth-child-recipes-sass-mixins/
Edit: Reason for wanting this functionality: In a CMS system, the "top heading" is used as the document title (post, page, etc.). However, it remains visible on the page, causing the title to appear twice - once as the post title and once in the body. JavaScript cannot be used. The top level of the h*
may vary.