Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use <article> or <div>? [closed]

Tags:

html

css

I'm new to web layout so forgive me if my question seems amateurish. I am trying to layout a landing page consisting of text boxes which will contain links to other pages on the site. The rough design is here:

http://silvercoastlife.com/wptest/landing-page-tester/

So far I have been using div to define the elements on the page but now I have come across article and wonder if I should be using this instead, especially as for SEO purposes I would like each box to have individual h1 headlines.

Thank you in advance for any advice you can offer.

like image 402
Connal Vickers Avatar asked Jan 06 '16 09:01

Connal Vickers


People also ask

Should I use div or article?

So which should you use and when? If the content within the element is not semantically related, then use a <div> . If the semantically related content is also able to be self-contained, then use an <article> .

Can I use article instead of div?

The article tag is mainly used for displaying content like blog posts, stories or articles. It can be used instead of the div tag to create more semantic meaning to your codebase. The article tag does not come with specific or different styles on the browser.

Do div tags need to be closed?

Div tag has both open(<div>) and closing (</div>) tag and it is mandatory to close the tag. The Div is the most usable tag in web development because it helps us to separate out data in the web page and we can create a particular section for particular data or function in the web pages.

Why should I not use div?

The primary issue with heavy use of <div> tags is that they lack semantic meaning. Writing Semantic HTML gives your markup meaning to web browsers and screen readers, can help with SEO, makes it easier to debug code, and more. According to the W3C: “The div element has no special meaning at all…


1 Answers

Article would generally be wrapped in a <div> in HTML4, and the subsections would only be suggested by <h1>-<h6> elements. In HTML5 the article should be wrapped in <article>, and the subsections of the <article> should be explicitly indicated by wrapping them in <section> elements, perhaps in ordered list items if you’d like section numbering.

<article>
    <h1>Title</h1>
    <section>
        <h2>Section title</h2>
        <p>Content</p>
    </section>
    <section>
        <h2>Section title</h2>
        <p>Content</p>
    </section>
    <section>
        <h2>Section title</h2>
        <p>Content</p>
    </section>
</article>

For more you can use this reference.

like image 108
Suvro Avatar answered Oct 10 '22 06:10

Suvro