Re: [csswg-drafts] [selectors-5] add new selector immediate-adjecent-child

I have been trying to summarise what I am missing the last 2 hours, but it's a lot to take in.
I will come back to this ticket as soon as I can set up a clear example to demonstrate exactly what I need.

For now I will try my best:
I am trying to set up a website using a framework. Each page the framework will handle has a different structure, but they all use the same main.css external style sheet. I am trying to add a rule in the stylesheet to select the very first paragraph element, but only the very first, and have its letter a larger font size. Think of a newspaper, in which each acticle opens with a stylised letter. The rules I use to style the letter are not relevant to this issue. The issue is selecting exclusively the first paragraph encountered on the page, without selecting any other paragraphs which follow as child or sibling or even in the parents of this first paragraph.
I do not know ahead of time what the parent element of the first paragraph will be, so folowing selector will not be an option
`.something > p:first-of-type { }`

Currently the selector would look something like
`body > *:first-of-type > p:first-of-type { }`
which is obviously not a valid statement.

`body p:first-of-type { }`
will not work either, as it will select not only the first overall <p> element on the page, but also many other <p> elements wich ar ethe first of their type in their own parent.

simply trying
`p:first-of-type { }`
also selects each first <p> as a child of any parent on the page, instead of just the absolute first.

Sibling selectors such as + and ~ are useless in this case, as I do not know to what element that first <p> will be a sibling ahead of time. Again, the stylesheet is used for a dynamicly generated page (inside a framework)

Maybe what I need is magic, but since I am looking for the first element meeting the right conditions which will be encountered while parsing from the top of the page, it initially seems to me it is technicly possible to devise a pseudo-element or combinator for this.

The idea I am trying to convey is very simulair to the difference between ~ and +, in which the former (~) selects any sibling of the named type and the latter (+) selects only a sibling which immediatly follows upon.
In my case I need something not for siblings, but for children. For example, I want the first <p> element which follows on <body>, looking at nested elements before looking at siblings.

**I am even confused whether I am looking for a combinator or a pseudo-element at this point**
Made enough of a fool of myself for today, so I will leave it at this for now.

If anyone managed to pick up on what I am looking for and knows whether it deseves further discussion please add a comment.

P.s.:
the issue stems from unexpected behavior of the pseudo-element :first-of-type (unexpected to me that is). I expected I could use it to select the very first element of a spesific type across the page, but what it really does is select each first element of given type of each element on the page.

I will not be sleeping.

-- 
GitHub Notification of comment by Meteor0id
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2568#issuecomment-381363254 using your GitHub account

Received on Saturday, 14 April 2018 21:55:27 UTC