I'm a web developer and father from The Netherlands. I mostly do Frontend Web development, but I'm also known to dabble in PHP, MySQL and AWS. I'm interested in learning Vue and NodeJS.
Full-time web dev; JS lover since 2002; CSS fanatic. #CSSIsAwesome
I try to stay up with new web platform features. Web feature you don't understand? Tell me! I'll write an article!
He/him
I hope it does! 😁Though I should say, <div>s are still okay for many purposes, arguably most of the time. I feel like I should write an addendum, with all the attention this post is getting, just to say, "It's fine to use <div>! #NotAllDivs are bad!" The main point is to avoid using a <div> in two cases:
When the contents of a block have a specific semantic meaning that has a designated HTML element (<address>, <nav>, <code>, <data>, etc.)
When you would add a block to your Table of Contents if you had one, in which case you should use <article> if the block is the root of an entire self-contained piece of content that can be understood on its own (a blog post, news article, forum post, Tweet, Instagram post, etc.), or a <section> if it's only a part of a larger document that wouldn't make sense on its own
If there's no appropriate semantic element, and the block isn't important enough for the TOC, then use a <div>! And if you want to convey more about the semantics than HTML explicitly supports, you can use RDFa or the itemtype attribute and related attribute with a schema.org schema to convey extra info.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great post, thanks for this! I find myself using divs a lot and I really need to change my ways, this article will help me.
I hope it does! 😁Though I should say,
<div>
s are still okay for many purposes, arguably most of the time. I feel like I should write an addendum, with all the attention this post is getting, just to say, "It's fine to use<div>
! #NotAllDivs are bad!" The main point is to avoid using a<div>
in two cases:<address>
,<nav>
,<code>
,<data>
, etc.)<article>
if the block is the root of an entire self-contained piece of content that can be understood on its own (a blog post, news article, forum post, Tweet, Instagram post, etc.), or a<section>
if it's only a part of a larger document that wouldn't make sense on its ownIf there's no appropriate semantic element, and the block isn't important enough for the TOC, then use a
<div>
! And if you want to convey more about the semantics than HTML explicitly supports, you can use RDFa or the itemtype attribute and related attribute with a schema.org schema to convey extra info.