The HTML <article> Element

Publish in HTML Tutorial el 23/05/2025 15:30

The <article> element represents a self-contained composition in a document, page, application, or site that is independently distributable or reusable. This could be a forum post, a magazine or newspaper article, a blog entry, a product card, or any other independent item of content.


Key characteristics of <article>:

  • Should make sense on its own
  • Can be independently distributed or syndicated
  • Typically contains a heading (<h1>-<h6>) as a child
  • Can be nested (e.g., blog comments can be articles within the main article)

Basic Syntax


When to Use <article>

Use <article> for content that could stand alone in a different context. For example:

  • Blog posts
  • News stories
  • Forum posts
  • Product cards
  • User comments

Examples of <article> Usage


Example 1: Basic Blog Post

A simple blog post structure using <article>:

Play Code


Example 2: News Article

A news article with multiple sections:

Play Code


Example 3: Product Card

An e-commerce product card using <article>:

Play Code


Example 4: Article with JavaScript Interaction

An article with a "Read More" button that expands content:

Play Code


Example 5: Dynamic Article Loading with JavaScript

Loading articles dynamically from an array:

Play Code


Best Practices and Tips

  • Nesting: Articles can be nested when appropriate (e.g., comments within a blog post article)
  • Headings: Each article should typically have its own heading
  • Semantics: Use <article> only for content that is independently distributable
  • Accessibility: Articles help screen readers identify independent content sections
  • Styling: Use CSS to visually distinguish articles when multiple appear on a page

Common Mistakes to Avoid

  • Using <article> for content that isn't self-contained
  • Forgetting to include a heading within the article
  • Confusing <article> with <section> (they serve different purposes)
  • Overusing <article> when <div> would be more appropriate

También te puede interesar

HTML <style> Element
HTML <style> Element

The <style> HTML element contains style information for a document, or part of a document. ...

HTML <strong> Element
HTML <strong> Element

The <strong> element is used to indicate that its content has strong importance, seriousnes...

HTML <span> Element
HTML <span> Element

The <span> element is an inline container used to mark up a part of a text or document. Unl...

HTML <source> Element
HTML <source> Element

The <source> element is used to specify multiple media resources for media elements like &l...

HTML <small> Element
HTML <small> Element

The <small> element is used to represent side-comments and small print, typically for discl...

HTML <section> Element
HTML <section> Element

HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...