section tag vs article tag in semantics HTML

Hello, I've understood that section and article tags are both part of the main tag. My question is, does section and article work in pairs and are they only used with main tag or can they be used in an aside tag? Now, what's the difference between an article tag vs a section tag? From what I've read, a section time group a particular thing, but so does article tag, no ?
4 Replies
13eck
13eck4mo ago
If it's an aside then, by definition, it's not main or an article, right? Asides are the sidebars. Generally info related to—but not directly impacting—the main topic. The biggest difference between an article and a section is that an article can be taken whole-cloth and re-posted elsewhere and have no context lost.
The <article> HTML element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (e.g., in syndication). Examples include: a forum post, a magazine or newspaper article, or a blog entry, a product card, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/article You can have one, none, or many articles and sections in any given page. It's up to you, as the page author, to know when to use which and how often/how many.
Faker
FakerOP4mo ago
yeah I see, hmm aside is normally outside main but does it contain tags like section or article? section element works in pairs with header element? Like we need to know this particular section is related to what? An article make sense on its own but if we have a list of article, we need to figure out this list of article is related to what, this is where section tag comes in?
13eck
13eck4mo ago
The question to be asked should be: “does the content in the aside also belong on a section/article?” It’s all based on the content and context. But honestly, if it deserves to be an article then it shouldn’t be in an aside. Maybe a link to the article in the aside, but not in the aside proper.
Faker
FakerOP4mo ago
yeah I see, thanks !

Did you find this page helpful?