Semantics

HTML Article

Structuring Article Content

HTML article element represents standalone content, like blog posts.

What is the HTML Article Element?

The <article> element in HTML is used to represent a piece of content that stands alone in a document, application, or site. This could be a blog post, a news article, a forum post, or any other independent content. The <article> element is part of HTML5 and aims to bring more semantic meaning to web documents.

When to Use the Article Element

Use the <article> element when you have content that could be distributed or reused independently, such as:

  • A blog post
  • A news article
  • A forum post
  • A user comment
  • A product card or listing

The key criterion is that the content should make sense on its own, without requiring additional context.

Basic Example of an Article Element

Nested Articles for Independent Content

In some cases, you might have articles within articles. For example, comments or reviews could be considered articles within a main article. HTML supports this nesting, allowing each <article> to be a complete piece on its own.

Styling the Article Element

The <article> element can be styled using CSS just like any other HTML element. Here's an example of how you might style an article to improve readability and presentation.

Accessibility Considerations

The <article> element enhances accessibility by clarifying the structure of a document to assistive technologies. Screen readers can announce the start and end of an article, helping users navigate the content more effectively. Ensure that each <article> has a meaningful heading to improve navigation for all users.

Previous
Nav