Article Tag in HTML
The article tag in HTML5 is used to define independent content that can be used outside of the context of the main content. The article tag should have a self-contained meaning and can be used to define blog posts, news articles, forums, etc. Here is a step-by-step tutorial about the article tag in HTML5:
- Start with the basic HTML document structure, which includes the doctype declaration, head and body tags.
HTML Page Basic Structure Example
<!DOCTYPE html>
<html>
<head>
<title>Example of Article Tag</title>
</head>
<body>
</body>
</html>
- To define an article, wrap the content with the article tag, like so:
Example of Article Tag
<article>
<h2>Article Title</h2>
<p>This is an example of an article tag in HTML5. It can be used to define independent content, like blog posts or news articles.</p>
</article>
- Within the article tag, you can add other HTML elements, such as headings, paragraphs, images, etc. Here's an example of an article with additional content:
Article with other Tags
<article>
<h2>Article Title</h2>
<p>This is an example of an article tag in HTML5. It can be used to define independent content, like blog posts or news articles.</p>
<img src="image.jpg" alt="Article Image">
<p>The article tag should have a self-contained meaning, and can be used to define blog posts, news articles, forums, etc.</p>
</article>
- The article tag also supports accessibility features like ARIA roles, allowing assistive technologies to recognize and understand the purpose of the content within the tag.
Article with role attribute
<article role="article">
<h2>Article Title</h2>
<p>This is an example of an article tag in HTML5. It can be used to define independent content, like blog posts or news articles.</p>
<img src="image.jpg" alt="Article Image">
<p>The article tag should have a self-contained meaning, and can be used to define blog posts, news articles, forums, etc.</p>
</article>
- You can have multiple article tags within the same HTML document. Here's an example of a page with two articles:
Multiple Article Example
<article role="article">
<h2>Article 1 Title</h2>
<p>This is the first article.</p>
</article>
<article role="article">
<h2>Article 2 Title</h2>
<p>This is the second article.</p>
</article>
That's it! You now have a good understanding of how to use the article tag in HTML5 to define independent content.