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 Mark Tag: How to Highlight Text

The mark tag highlights text in HTML and shows that the text has relevance in the content. It adds a…

HTML Textarea Tag: How it Works with Examples

The HTML textarea tag gives users space to enter longer messages. This element helps build forms that accept feedback, comments,…

HTML Label Tag: How It Works with Examples

Forms need instructions so users know what to enter. You use the HTML label tag to give names to input…

HTML s Tag: How it Works with Examples

The HTML s tag places a line across text that has no longer value or does not hold importance. It…

HTML meta Tags for SEO

In this article, you will learn what HTML meta tags are and how they work. You also see how they…

How to Use HTML div Tag – Examples & Group Content

In this article, you will cover how to use div tag in HTML layout. It offers beginner to advanced code…

HTML kbd Tag: How to Show Keyboard Input with examples

The HTML<kbd> tag shows the keys that a user must press. This helps you to give instructions for commands or…

HTML meter Tag: Measurements with Examples

Purpose and use cases: The HTML meter tag shows a scalar value within a known range. You can use it…

HTML Elements and Tags: Elements vs Tags Explained

HTML builds web pages. It does this with elements and tags. Many new learners confuse them, so you need to…

HTML Table Tag: How to Build Tables with Its Elements

You use the HTML <table> tag to display structured data in rows and columns, using table elements such as <tr>…

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.