Re: A issue with p element outside a list

banyon.jarvis@lycos.com wrote:

> I have a nested unordered list that has the following style added in the
> style section within the head element.
>
As regards to markup validation, style sheet settings are completely
irrelevant. What matters is this:

> <p>
>
> <ul>
> <li>Hand sewn </li>
> <li>Machine sewn </li>
> <li>repairs pieced </li>
> <li>light cleaning </li>
> </ul>
> </p>
>

You have tried to include a <ul> element inside a <p> element. This is
forbidden by syntax rules, which say that a <p> element may only contain
“phrase elements”, which effectively means plain text and text-level markup:
https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element

Technically, what happens here is that the tag <p> opens a <p> element, but
it becomes empty, since the <ul> tag implicitly closes the open <p>
element, since <p> cannot contain <ul>. This leaves the end tag </p>
homeless.

The cure is to remove the <p> and </p> tags. This may affect vertical
spacing in the document, so you may wish to reconsider the settings for
vertical margins and spacing.

Yucca

P.S. I am not affiliated with the W3C in any way. I wonder if anyone from
the W3C reads this list. If not, perhaps it should be closed, or explained
in a different way (as a potential forum for peer support).

Received on Wednesday, 26 August 2020 17:32:27 UTC