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.
Table of Content
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.
Tag | Role | Reuse |
---|---|---|
<article> | Independent content | Can stand alone |
<section> | Group Thematic of content | Needs 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?
How do I use the tag with other HTML tags?
<section>
<article>
<header>
<h2>Title</h2>
</header>
<p>Content here.</p>
</article>
</section>
What is the difference between and in HTML?
Can I put a inside an tag?
<article>
<div>Box 1</div>
<div>Box 2</div>
</article>
Is the tag required for SEO in HTML5?
Similar Reads
The title tag in HTML shows the page name in the browser tab and helps search engines know the topic.…
The <dialog> tag is used to build modal popups in HTML. It shows alerts and messages without third-party scripts. Understand…
The HTML input tag lets you add fields for user data in forms. You use this tag to collect text,…
HTML global attributes work on most elements. They do not depend on the tag name. You can use them with…
The HTML time Tag marks time values in a document. Use it to show dates or times that machines and…
The form autocomplete attribute in HTML helps users fill out forms faster because it shows them saved input for common…
The nav tag defines a navigation block in HTML. It holds main links to other parts of your site. Search…
The HTML a tag allows you to create links that move users from one page or resource to another. Understand…
The <details> tag hides content and shows it when needed. It helps organize long pages. The tag shows extra info…
The HTML span tag acts as a simple container for inline text or other inline elements. It groups text and…