Hello, I have a blog, and the page that lists all the blog posts uses the following markup. I hand-coded this markup myself, and I mention this because it’s not the default setup of the blog.
Since the post summary doesn’t have a heading, the W3C validator suggests that I should use a <div> instead. Is that correct? It’s not that I don’t trust the validator, and I know my question might sound a bit silly, but is it okay to use a <div> in this situation? Does it work well with the <header> and <footer> elements line in my markup?
I would like to add some spacing between these elements, and I’d prefer to target their containers rather than the elements themselves. Also, I believe using headings and footers can enhance the semantic meaning of the content as shown on the MDN page: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article
Semantically, this makes more sense (to me at least), though I could argue the div isn’t needed at all (you can just as easily style to .blog article as you can .blog-container article).
So either move it below the h2 or remove it all together.
It’s the sections in the articles that is throwing it for a loop. Article is a specific type of document element, and section doesn’t typically fall under the article. A better element would be main in that case, but main is restricted to the body level.
So in this case, div instead of section would be appropriate - unless you’re always going to just have a paragraph in the summary, in which case, just use the p element.