In the new version of the Validator (perhaps present in previous versions, but I didn't notice it until I installed the new version), headings wrapped in DIVs that are a child element of a SECTION are not recognized by the validator. For example:
The Validator issues this warning on the <section>:
No heading element was found as a child of this <section> element. Each section should typically be identified by including a child heading element (<h1>, <h2>, <h3>, etc.).
This warning seems wrong; the DIV seems to hide the <h2> from the validator.
CSS HTML Validator is only looking for headings in the children, so it won't see a heading if it's in a child element and not the child element itself. This is because https://developer.mozilla.org/en-US/doc ... sage_notes says "each <section> should be identified, typically by including a heading (<h1> - <h6> element) as a child of the <section> element". Note that it says child and not descendant.
However, I ran this through the Nu Html Checker and it accepted (by not generating a warning) the heading element when it was a descendant.... so I will go ahead and have CSS HTML Validator look for heading elements as descendants and not just as children in <section> elements
I believe the reasoning is that DIVs are only used for styling, so they're discounted over other elements, but if so, the documentation at Mozilla should be clearer.
TomHTML wrote: ↑Sat Jul 23, 2022 6:06 pm
Thanks for attending to this so quickly!
I believe the reasoning is that DIVs are only used for styling, so they're discounted over other elements, but if so, the documentation at Mozilla should be clearer.
Thanks again!
You're welcome!
Yes, the documentation at Mozilla may need to be clearer and/or revised... but <div> elements are general sectional elements that can be used for styling but also for a general "related content section" when another sectioning element like <article>, <nav>, <section>, etc. isn't appropriate (or as Mozilla says, the <div> element is a generic container for flow content).