- From: Michael[tm] Smith <mike@w3.org>
- Date: Tue, 2 Jun 2020 09:48:11 +0900
- To: Joseph Polizzotto MA <jpolizzotto@berkeley.edu>
- Cc: www-validator@w3.org
- Message-ID: <20200602004811.GK2181@sideshowbarker.net>
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
Received on Tuesday, 2 June 2020 00:48:28 UTC