I'm new to HTML and programming in general and I want to make sure my code is organized and that I'm using the best practices while I go along.
So, I made this example layout I would like to convert to HTML5:
And this is the HTML5 code I created:
<!-- Solutions Section -->
<section id="Solutions">
<header>
<h1>Title</h1>
<h2>Subhead</h2>
</header>
<!-- Items -->
<section>
<article class="Solutions_items">
<!-- Should I have a <header> inside each article? -->
<h1>Item 1</h1>
<p>Lorem ipsum...</p>
</article>
<article class="Solutions_items">
<h1>Item 2</h1>
<p>Lorem ipsum...</p>
</article>
<article class="Solutions_items">
<h1>Item 3</h1>
<p>Lorem ipsum...</p>
</article>
</section>
</section>
Now to the questions:
Is there a difference between using
div
instead ofsections
orarticles
? I mean, not only in the organization realm but also in optimization realm? Is there a general best practice convention nowadays about this specific topic? Because I feel that usingsections
andarticles
makes the code easier to read (and also makes the CSS file cleaner).Should I have a
header
tag inside eacharticle
? I heard this is best practice but I feel like this would make the code harder to read and at the same time I feel like it makes the code more organized so I'm kind of confused what to do.About code readability: Should I keep a line break between different items like
sections
? In a small HTML file I'm aware that like breaks wouldn't be a big deal but in a big HTML file you could have like 200 empty lines making the code way bigger than it has to be. What do people usually do about this?