Re: Nu-HTML checker - <details> as child of <figure>?

Our situation was indeed the first case:

<figure>
  <img src=foo alt=bar>
  <figcaption>...</figcaption>
  <details><summary>...</summary></details>
</figure>

Though we would prefer that <details> came immediately after <figcaption>,
we can change our script to achieve this confirming case:

<figure>
  <figcaption>...</figcaption>
  <img src=foo alt=bar>
  <details><summary>...</summary></details>
</figure>

Thanks again,

Joseph


On Mon, Jun 1, 2020 at 5:48 PM Michael[tm] Smith <mike@w3.org> wrote:

> For the figure element, the HTML defines the following content model:
>
>
> https://html.spec.whatwg.org/multipage/#the-figure-element:concept-element-content-model
>
> > Either: one figcaption element followed by flow content.
> > Or: flow content followed by one figcaption element.
> > Or: flow content.
>
> So an example of a non-conforming case would be something like this:
>
> <figure>
>   <img src=foo alt=bar>
>   <figcaption>...</figcaption>
>   <details><summary>...</summary></details>
> </figure>
>
> That example would cause the checker to report an "Element “details” not
> allowed as child of element “figure” in this context" error.
>
> Specifically, the spec requirements don’t allow content both before and
> after the figcaption element — either the figcaption must be the first
> child of the figure, or it must be the last child.
>
> But both of the following would be conforming, and would not cause the
> checker to report any error.
>
> <figure>
>   <figcaption>...</figcaption>
>   <img src=foo alt=bar>
>   <details><summary>...</summary></details>
> </figure>
>
> <figure>
>   <img src=foo alt=bar>
>   <details><summary>...</summary></details>
>   <figcaption>...</figcaption>
> </figure>
>
> Joseph Polizzotto MA <jpolizzotto@berkeley.edu>, 2020-06-01 16:34 -0700:
> > Archived-At: <
> https://www.w3.org/mid/CAGQNLEUAvA_hYSGV9A8mCMhY9wb-9b_n_n3FVZinW5gHkGSmEQ@mail.gmail.com
> >
> >
> > I would like to use <details> as a child of <figure> but get an error
> > message when running the Nu-HTML checker.
> >
> > error: Element “details” not allowed as child of element “figure” in this
> > context. (Suppressing further errors from this subtree.)
> >
> > I believe my use of <details> as a child of <figure> is flagged because I
> > am also using <figcaption> within the same <figure>. When <details> is a
> > child of <figcaption> within the <figure>, the error goes away.
> >
> > I also noticed that when I use <details> as a child of <figure> that does
> > not have <figcaption>, there is no error.
> >
> > I am wondering why the Nu_HTML validator allows <details>1) as a child of
> > <figcaption> and 2) as a child of <figure> when there is no <figcaption>,
> > but not 3) as a child of <figure>, which also has <figcaption>.
> >
> > Note: I have tested <details> as a child of <figure> with a <figcaption>
> > with Firefox, Chrome, and Edge and noticed that these browsers do support
> > this combination.
> >
> > Thanks for your help,
> >
> > Joseph
> >
>
> --
> Michael[tm] Smith https://people.w3.org/mike
>


-- 
*Alternate Media Supervisor*
Disabled Students' Program
University of California, Berkeley
https://dsp.berkeley.edu/
<https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdsp.berkeley.edu%2F&data=02%7C01%7C%7C4e0abffcb5b34567a22308d5e13137b3%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636662523854357148&sdata=yB5%2BUm2W6TBwpc%2BOF4DvN8wPoo1dozUwz8eCepYhTyY%3D&reserved=0>
(510) 642-0329

Received on Tuesday, 2 June 2020 15:59:56 UTC