HTML Article Tag: How to Create Semantic Content

html article tag

Semantic article tag in HTML uses clear tags that show the role of each part. These tags tell browsers and people what the content means.

The tag like <article> points to independent content. It helps search engines read the page better.

What is the <article> Tag in HTML?

The <article> tag shows a block of content that stands alone. You can move this block to other pages. It will still make sense by itself. This can be a blog post or a news story.

The syntax looks like this. Use this format when you write your code.

<article>
  Content goes here.
</article>

You write it like this to mark content as independent. The start tag begins the article. The end tag closes it. Any content inside the tags stays grouped as one unit.

The <article> tag helps browsers and tools read content as a single piece. This tag groups related text or media in one block. It also helps assistive tools find and show the main idea of the page.

Let’s look at an example to understand better.

<article>
  <h2>How to Plant Tomatoes</h2>
  <p>Tomatoes grow well in warm soil. Water them every few days.</p>
</article>

The heading names the topic. The paragraph gives steps. You can move this code to another page.

Nest and Combine <article> Tag with Other Tags in HTML

You can nest <article> inside other tags. You can also put tags inside <article>.

Take this example.

<section>
  <article>
    <h2>Local News</h2>
    <p>The city starts a new recycle plan.</p>
  </article>
  <article>
    <h2>Sports Update</h2>
    <p>The team wins the match last night.</p>
  </article>
</section>

This code puts two articles inside a section. Each article shows a story. The section groups the stories under a shared theme.

Consider this use case.

<article>
  <header>
    <h2>Recipe: Pancakes</h2>
  </header>
  <p>Mix flour and eggs and Cook on a hot pan.</p>
  <footer>
    <p>Author: Sam</p>
  </footer>
</article>

This example uses <header> and <footer> inside an article. The header shows the title. The footer shows extra info. The main text sits in the middle.

The Difference Between <article> and <section>

The <article> tag holds content that stands alone. You can take it out and read it alone.

The <section> tag groups content by theme. You use it to split a page into parts.

Here is a table that shows the key differences.

TagRoleReuse
<article>Independent contentCan stand alone
<section>Group Thematic of contentNeeds context

The <article> tag fits blog posts or product details. The <section> tag fits groups of related content on one topic.

How to Style the <article> Tag with CSS

You can style the <article> tag to look clear and neat. Here’s an example CSS.

article {
  border: 1px solid #ccc;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #f9f9f9;
}

This CSS adds a border and padding. It also sets the spaces between articles and a background color.

Examples of <article> Tag in HTML

Blog Post Article:

<article>
  <h2>Tips of how to bake the Bread</h2>
  <p>Bread needs time to rise. Use fresh yeast and warm water for best results.</p>
</article>

This example shows a blog post about how to bake bread. The heading names the topic. The paragraph gives details. The code groups them as one unit.

News Story Article:

<article>
  <h2>Storm Hits Coast</h2>
  <p>Heavy rain floods streets. Officials warn drivers to stay home.</p>
</article>

This example shows a news story. It stands alone. You can copy it to another site.

Product Description Article:

<article>
  <h2>Wireless Headphones</h2>
  <p>These headphones play music for 20 hours. They charge in 2 hours.</p>
</article>

This article gives product details. It works well in a product catalog.

Recipe Article:

<article>
  <h2>Simple Salad</h2>
  <p>Mix tomatoes and cucumbers then add olive oil and salt.</p>
</article>

This article shows a recipe. It groups the steps as one complete piece.

Tutorial Article:

<article>
  <h2>How to Install a Plugin</h2>
  <p>Go to the plugin page. Click install. Wait for the message that says complete.</p>
</article>

This example shows a tutorial. It guides the reader step by step. The article tag holds the instructions together.

Wrapping Up

In this article, you learned what <article> means. You read how to write it and style it, and saw how to group it and when not to use it.

Here is a quick recap:

  • Use <article> for content that can stand alone.
  • Use the tag for full stories or posts.
  • Combine it with <section> and semantic parts.
  • Style it with borders and spaces.
  • Use it only once per self-contained block.

FAQs

What does the tag do in HTML?

The <article> tag marks a block of content that stands on its own. This can include blog posts, news entries, or tutorials. The tag defines a self-contained unit.

How do I use the tag with other HTML tags?

You can use <article> inside a <section>. You can also place semantic tags like <header> or <footer> inside it. For example:

<section>
  <article>
    <header>
      <h2>Title</h2>
    </header>
    <p>Content here.</p>
  </article>
</section>

What is the difference between and in HTML?

Use <article> for full units of content. These must make sense without other elements. Use <section> to group related blocks that need a shared heading.

Can I put a inside an tag?

Yes. <div> is a generic container. You can place it inside <article> to hold layout blocks. For example:

<article>
  <div>Box 1</div>
  <div>Box 2</div>
</article>

Is the tag required for SEO in HTML5?

No. The tag is not required. But it helps search engines read your structure. Clear tags like <article> make indexing easier.

Similar Reads

HTML title Tag: How to Set Web Page Titles

The title tag in HTML shows the page name in the browser tab and helps search engines know the topic.…

HTML dialog Tag: How to Create Dialog Boxes

The <dialog> tag is used to build modal popups in HTML. It shows alerts and messages without third-party scripts. Understand…

HTML Input Tag: How It Works, Types & Examples

The HTML input tag lets you add fields for user data in forms. You use this tag to collect text,…

HTML Global Attributes Overview

HTML global attributes work on most elements. They do not depend on the tag name. You can use them with…

HTML time Tag: Representing Dates and Times

The HTML time Tag marks time values in a document. Use it to show dates or times that machines and…

HTML autocomplete Attribute: How to Use it with form and input

The form autocomplete attribute in HTML helps users fill out forms faster because it shows them saved input for common…

HTML Nav Tag: How to Create Navigation Menus

The nav tag defines a navigation block in HTML. It holds main links to other parts of your site. Search…

HTML a Tag: How to Add Links to Web Page with Examples

The HTML a tag allows you to create links that move users from one page or resource to another. Understand…

HTML details Tag: How to Toggle Hidden Content

The <details> tag hides content and shows it when needed. It helps organize long pages. The tag shows extra info…

HTML Span Tag: Inline Container Explained

The HTML span tag acts as a simple container for inline text or other inline elements. It groups text and…

Previous Article

HTML Footer Tag for Document Footers

Next Article

The em Tag in HTML: How to Emphasize Text in HTML

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *


Subscribe to Get Updates

Get the latest updates on Coding, Database, and Algorithms straight to your inbox.
No spam. Unsubscribe anytime.