What is the Article Tag in HTML: Definition and Usage
<article> tag in HTML defines a self-contained piece of content that can stand alone, like a blog post or news story. It helps organize web pages by marking sections that make sense on their own.How It Works
The <article> tag works like a container for content that forms a complete, independent part of a webpage. Imagine a newspaper: each article is a separate story that can be read on its own. Similarly, the <article> tag groups content such as a blog post, a news item, or a forum post.
This tag helps browsers and search engines understand the structure of your page better. It also improves accessibility by letting screen readers identify distinct sections clearly. Using <article> is like putting each story in its own box, making the page easier to read and organize.
Example
This example shows two articles on a webpage, each with a heading and some text. Each <article> stands alone as a separate piece of content.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Article Tag Example</title> </head> <body> <article> <h2>My First Blog Post</h2> <p>This is the content of my first blog post. It talks about web development basics.</p> </article> <article> <h2>News Update</h2> <p>Today, a new technology was released that will change how we build websites.</p> </article> </body> </html>
When to Use
Use the <article> tag whenever you have content that can stand alone and be shared or reused independently. Examples include:
- Blog posts
- News stories
- Forum posts or comments
- User-submitted content
- Product descriptions or reviews
This helps organize your page clearly and improves SEO and accessibility. Avoid using <article> for generic layout or styling purposes.
Key Points
- The
<article>tag defines a self-contained, independent piece of content. - It improves page structure, SEO, and accessibility.
- Each
<article>should make sense on its own. - Common uses include blog posts, news items, and forum entries.
- Do not use it just for styling or layout.