HTML
Article Tag


The <article> tag in HTML is used to define independent, self-contained content within a webpage. This content is usually relevant on its own and can be distributed or reused independently from the rest of the page. It is often used for things like blog posts, news articles, or individual pieces of content that have their own meaning and context.

Syntax:

<article> Content of the article </article>

Purpose:

The <article> tag is designed to hold content that makes sense on its own. This could be:

  • A news story
  • A blog post
  • A user comment
  • A product description
  • A forum post
  • Any self-contained piece of content

Key Characteristics:

  • Independent Content: An <article> represents a section of content that can stand alone. It could be shared or repurposed without losing its context.
  • Structured Semantics: Using the <article> tag helps search engines and screen readers better understand the structure of the webpage. This boosts accessibility and SEO (search engine optimization).

Example:

<article> <h2>The Benefits of Learning HTML</h2> <p>HTML is the foundation of web development and understanding it can help you build websites and web applications...</p> <p>Learning HTML is a great way to start your journey in web development.</p> </article>

In this example:

  • The <article> contains a complete blog post with a heading (<h2>) and two paragraphs (<p>).
  • This article can stand alone and be distributed or republished without needing additional context.

Example with Multiple <article> Tags:

On a news website or blog, multiple <article> elements might be used:

<section> <article> <h2>Breaking News: New Technology Released</h2> <p>Today, a new tech product was announced that will change the industry...</p> </article> <article> <h2>Opinion: The Future of Tech</h2> <p>The tech industry is rapidly evolving, and we must adapt to new trends...</p> </article> </section>

Here, two articles are grouped within a <section>, but each <article> can be read and understood independently.

Differences from Other Semantic Tags:

  • <section>: The <section> tag is used for grouping related content, while an <article> is meant for self-contained content. A section might contain multiple articles or subsections.
  • <div>: A <div> is a generic container with no semantic meaning, while the <article> tag provides clear meaning to the content.
  • <aside>: The <aside> tag is used for related but non-essential content (like sidebars or pull quotes), while <article> contains the main, self-contained content.

Accessibility and SEO:

  • Screen Readers: The <article> tag helps screen readers understand that the enclosed content is a standalone piece, improving accessibility for users with disabilities.
  • SEO: Search engines give more importance to well-structured HTML, so using <article> helps with search engine optimization (SEO), as search engines recognize this as significant, standalone content.

Use Cases:

  • Blog Post: A complete blog entry can be wrapped in an <article> tag.
  • News Story: A news report on a webpage can be defined as an article.
  • Product Details: A product description on an e-commerce site can be wrapped in an <article>.