The HTML <article> tag is a semantic element in HTML5. It’s used to represent a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable.
When to Use the <article> Tag
The <article> tag should enclose content that forms an independent part of a document or site. This could be a forum post, a magazine or newspaper article, a blog post, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.
How to Use the <article> Tag
<!-- Here's an example of how you might structure an article --> <article> <h2></h2> <p></p> <p></p> </article>
In this example above, we have an article with two paragraphs and one heading. The heading describes the topic of the article and each paragraph contains related information.
You can also nest articles within each other if it makes sense to do so. For instance:
<!-- Here's an example of nested articles --> <article> <h2></h2> <p></p> <p></p> <!—- Nested Article —-> <article>> <h3></h3> <p></p> </article> </article>
In the example above, we have an article within another article. This could be useful if you have a main article and then a related sub-article.
The HTML <article> tag is a powerful tool for structuring your content in a meaningful way. It helps search engines understand the structure of your content, which can improve SEO. Remember to use it when you’re creating self-contained, distributable pieces of content!