Horje
How to create HTML <article> Element

The <article> element specifies independent, self-contained content.

An article should make sense on its own, and it should be possible to distribute it independently from the rest of the web site.

Examples of where the <article> element can be used:

  • Forum posts
  • Blog posts
  • User comments
  • Product cards
  • Newspaper articles

Example of HTML <article> Element

Three articles with independent, self-contained content:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h1>The article element</h1>
<article> <h2>Google Chrome</h2> <p>Google Chrome is a web browser developed by Google, released in 2008. Chrome is the world's most popular web browser today!</p>
</article>
<article> <h2>Mozilla Firefox</h2> <p>Mozilla Firefox is an open-source web browser developed by Mozilla. Firefox has been the second most popular web browser since January, 2018.</p>
</article>
<article> <h2>Microsoft Edge</h2> <p>Microsoft Edge is a web browser developed by Microsoft, released in 2015. Microsoft Edge replaced Internet Explorer.</p>
</article>
</body>
</html>

Output should be:

Example of HTML <article> Element

Example 2 of HTML <article> Element

Use CSS to style the <article> element:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
.all-browsers { margin: 0; padding: 5px; background-color: lightgray;
}
.all-browsers > h1, .browser { margin: 10px; padding: 5px;
}
.browser { background: white;
}
.browser > h2, p { margin: 4px; font-size: 90%;
}
</style>
</head>
<body>
<article class="all-browsers"> <h1>Most Popular Browsers</h1> <article class="browser"> <h2>Google Chrome</h2> <p>Google Chrome is a web browser developed by Google, released in 2008. Chrome is the world's most popular web browser today!</p> </article> <article class="browser"> <h2>Mozilla Firefox</h2> <p>Mozilla Firefox is an open-source web browser developed by Mozilla. Firefox has been the second most popular web browser since January, 2018.</p> </article> <article class="browser"> <h2>Microsoft Edge</h2> <p>Microsoft Edge is a web browser developed by Microsoft, released in 2015. Microsoft Edge replaced Internet Explorer.</p> </article>
</article>
</body>
</html>

Output should be:

Example 2 of HTML <article> Element





Related Articles
HTML Semantic HTML Semantic
Semantic Elements in HTML HTML Semantic
How to create HTML <section> Element HTML Semantic
How to create HTML <article> Element HTML Semantic
Nesting <article> in <section> or Vice Versa HTML Semantic
How to create HTML <header> Element HTML Semantic
How to create HTML <footer> Element HTML Semantic
How to create HTML <nav> Element HTML Semantic
How to create HTML <aside> Element HTML Semantic
How to create HTML <figure> and <figcaption> Elements HTML Semantic
Why Semantic Elements? HTML Semantic

Single Articles
Example of HTML <article> Element HTML Semantic
Example 2 of HTML <article> Element HTML Semantic

Category :
Web Tutorial
Sub Category :
HTML Semantic
Uploaded by :
Admin


Read Article
https://horje.com/learn/1434/reference