Syntax
The HTML <article>
component is used as follows:
1 |
<article>
|
2 |
<!-- Content material goes right here -->
|
3 |
</article>
|
Instance
Let’s say you’ve gotten a weblog and need to write an article about the advantages of meditation. Right here’s an instance of how you can construction your HTML utilizing the <article>
component:
1 |
<foremost>
|
2 |
<article>
|
3 |
<h2>The Advantages of Meditation</h2> |
4 |
<p>Meditation has been proven to cut back stress, enhance focus, and increase total well-being. This text will discover the various advantages of this historic observe.</p> |
5 |
<img src="meditation.jpg"alt="An individual meditating"> |
6 |
<h3>Decreased Stress</h3> |
7 |
<p>Research have proven that meditation can decrease cortisol ranges, the hormone related to stress. Frequently working towards meditation can cut back anxiousness and make you are feeling extra relaxed in your every day life.</p> |
8 |
<h3>Improved Focus</h3> |
9 |
<p>Via meditation, you'll be able to enhance your capacity to pay attention and keep targeted on the duty at hand. This may be particularly useful for many who battle with distractions or have a busy thoughts.</p> |
10 |
<h3>Higher Sleep</h3> |
11 |
<p>By quieting your thoughts and enjoyable your physique, meditation may also help you go to sleep quicker and revel in a extra restful sleep. It can be efficient in treating insomnia and different sleep problems.</p> |
12 |
</article>
|
13 |
</foremost>
|
Outcome
Attributes
The <article>
component has solely one attribute: class
. This attribute is used to use a category to the component, which can be utilized to fashion the content material or apply JavaScript conduct. Right here’s an instance:
1 |
<article class="featured"> |
2 |
<!-- Content material goes right here -->
|
3 |
</article>
|
The featured
class has been utilized to the <article>
component on this instance. This class might be used to fashion the article uniquely, similar to making it stand out on the web page.
Content material
The <article>
component can include any HTML content material, together with headings, paragraphs, photographs, movies, and extra. The content material must be self-contained and concentrate on a single subject or concept. When utilizing a number of <article>
parts on a web page, it’s good observe to incorporate a heading inside each, which may enhance the general readability of the content material.
- There are a number of different sectioning parts, helpful for splitting up content material on a web page in a descriptive manner:
<article>
,<apart>
,<kind>
,<header>
,<footer>
,<foremost>
,<nav>
, and<part>
are all sectioning parts.
Did You Know?
- The
<article>
component was launched in HTML5 to mark up self-contained content material semantically. - Utilizing the
<article>
component can enhance the accessibility and web optimization of your web site, because it helps search engines like google and yahoo and display readers perceive your content material’s construction.