+ 1

<article> or <div>?

hey Im confused... when to use <article> and when to use <div>? ain't it close to the same?

13th Sep 2016, 9:26 AM
Emma Hjortsberg
Emma Hjortsberg - avatar
6 Respuestas
+ 2
<article> and several other new tags of html5 like <header>, <footer>, <aside>, <section>, etc. are meant to indicate what the block contains and/or where it is positioned on the page. <article> defines an article in the document (a blog post, a forum post, etc.). <div> is a more general purpose tag to contain a block of code. In html4, you often had things like <div class="header">, <div class="footer">, etc. with some associated css, and they were given their own tag in html5 to simplify things.
13th Sep 2016, 10:21 AM
Zen
Zen - avatar
+ 1
Using <article> instead of <div class="article"> doesn't change much the css you have to write. However, adding a class to elements you want to select (that are not <article>, <header>, etc.) does, and I would recommend to do so. In general, put a class indicating the purpose of the element, because you generally want the same style applied to all of those elements.
14th Sep 2016, 10:24 AM
Zen
Zen - avatar
0
làm sao
13th Sep 2016, 9:47 AM
Giáp Xuân
Giáp Xuân - avatar
0
thanks zen! does that mean that <div> should be used to make work with css easier?
13th Sep 2016, 12:17 PM
Emma Hjortsberg
Emma Hjortsberg - avatar
0
When using any HTML5 tags for layouting you may have some limitations! Consider using DIV and you will have no problems.
13th Sep 2016, 5:11 PM
Scotti
Scotti - avatar
0
thanks guys!
14th Sep 2016, 6:41 AM
Emma Hjortsberg
Emma Hjortsberg - avatar