Re: [csswg-drafts] Unexpected behaviour selecting <picture> element (#3818)

For the purposes of CSS, a `<picture>` element acts the same as a `<span>`.  It isn't the element that draws the image, and by default it doesn't have any styles, but you can style it if you want.

If [`display: contents`](https://drafts.csswg.org/css-display-3/#box-generation) had existed when the picture element was added, a picture might have been defined to use that rule, creating a container that isn't drawn at all, just passing through its child contents.  _But,_ even if a `<picture>` had `display: contents`, and was therefore removed from the CSS layout rendering tree, your selector still would not work.

Selectors operate on the DOM tree, not on the rendering tree.  The `<img>` element is not a direct child of the `<div>` in your DOM tree, it is a direct child of `<picture>`.  Your `<img>` element _is_ a descendent of your `<div>` in the DOM tree, so the descendent combinator works fine.



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

Received on Thursday, 11 April 2019 00:03:36 UTC