Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is <article> tag of HTML5 only to use in blogs?

Tags:

html

Is the article tag of HTML5 only to use in blogs? Is it only for blog articles? Is it not to use for the content section of website, which is not a blog?

Generally I use

<div id="content">
<h2> title </h2>
<p> content </p>
</div>

Should I replace div with article

<article id="content">
<h2> title </h2>
<p> content </p>
</article>

or

<div id="content">
<article>
<h2> title </h2>
<p> content </p>
</article>
</div>
like image 717
Jitendra Vyas Avatar asked Nov 29 '25 16:11

Jitendra Vyas


2 Answers

From the spec:

The article element represents a component of a page that consists of a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.

So I guess it is quite dependant on what #content contains. If it would only contain that specific article (or stuff related to that article, like comments nested as further articles), you do not need the div.

My favourite resource about this - HTML5Doctor

like image 76
kapa Avatar answered Dec 01 '25 06:12

kapa


There's some nice detail about the article element at html5doctor.

In a nutshell, <article> is not limited to blogs and your example

<article id="content">
<h2> title </h2>
<p> content </p>
</article>

would seem to be an ideal use of <article>.

like image 28
Kalessin Avatar answered Dec 01 '25 07:12

Kalessin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!