article element flexbox issue

Hi, so i'm trying to make this a flexbox with the h2 and p on the left and the image on the right but if i do this as it is, html validator yells at me saying that i need the h2 to be a direct child to the article element. How else am i suppose to group the h2 nd p within the article tags without having them in a parent div to make a flexbox? @Kevin <article> <div> <h2>lorem ipsum</h2> <p>lorem ipsum veteri ingnisei</p> </div> <img src= "/pathtoimage" alt= "some image"> </article>
12 Replies
glutonium
glutonium3y ago
share the css as well if u want the h2 and p on the left and img on the right using flexbox..u can do it as follows
<article>
<div>
<h2></h2>
<p></p>
</div>

<img src = "#">
</article>
<article>
<div>
<h2></h2>
<p></p>
</div>

<img src = "#">
</article>
article{
display: flex;
}
article{
display: flex;
}
this should work
Monimolimnion
Monimolimnion3y ago
Doesn't solve the html validation problem though... Though I've just run it through the w3.org validator and it doesn't bat an eyelid
The builder
The builderOP3y ago
that's weird, I just ran another check and it seems to be fine it.
Monimolimnion
Monimolimnion3y ago
I was dubious about it when you first mentioned it tbh
glutonium
glutonium3y ago
html validation?? this is the first time I'm hearing this.. what's it about
Monimolimnion
Monimolimnion3y ago
Read op's question again Though it seems to be a non issue which makes sense to me
Jochem
Jochem3y ago
considering divs aren't supposed to have any semantic meaning, it makes sense that it would validate there's online validators that will check your HTML for structural issues, including the w3c workgroup one: https://validator.w3.org/
glutonium
glutonium3y ago
so if the structure is not correct then the html is invalid??
Jochem
Jochem3y ago
yes? browsers will do their best to turn even the worst garbage into a valid document, but it can cause unpredictable behavior
glutonium
glutonium3y ago
hmm i see gotcha..tnx
Chris Bolson
Chris Bolson3y ago
The only issue I can imagine coming up for an H2 is if there isn't an H1 somewhere before it.
glutonium
glutonium3y ago
HMMM

Did you find this page helpful?