W3C home > Mailing lists > Public > public-css-archive@w3.org > April 2019

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

From: Amelia Bellamy-Royds via GitHub <sysbot+gh@w3.org>
Date: Thu, 11 Apr 2019 00:03:16 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-481915836-1554940995-sysbot+gh@w3.org>
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

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:46 UTC