Hi everyone, this is my first time posting so I hope I have included this in the correct section and formatted this post acceptably!
I have just completed the Dasmoto Arts and Crafts project in Build a Website with HTML and CSS. I did not use div tags to structure my HTML, whereas the solutions did.
My questions are:
-
Why use div tags if class (or id) attributes can be written inside the h2 elements instead?
-
Is this for HTML readability? Or is it to develop these habits early, before code becomes longer and more complicated?
-
Unlike the Solutions, I styled the font size in CSS using the h2 selector, rather than defining the class ‘item’ as the solutions have . Is there a benefit to using the class selector over the h2 selector, with the greater specificity?
Thanks in advance for your advice!
The Codecademy Solution HTML
<!-- Brushes Section -- >
<div class="item">
<h2 id="brush">Brushes</h2>
<img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-2/hacksaw.jpeg"/>
<h3>Hacksaw Brushes</h3>
<p>Made of the highest quality oak, Hacksaw brushes are known for their
weight and ability to hold paint in large amounts. Available in
different sizes. <span class="price">Starting at $3.00 / brush.
</span></p>
</div>
<!-- Frames Section -- >
<div class="item">
<h2 id="frame">Frames</h2>
<img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-2/frames.jpeg"/>
<h3>Art Frames (assorted)</h3>
<p>Assorted frames made of different material, including MDF, birchwood,
and PDE. Select frames can be sanded and painted according to your
needs. <span class="price">Starting at $2.00 / frame.</span></p>
</div>
My HTML
<h2 class="brushes">Brushes</h2>
<img src="./resources/brushes.jpg" alt="a pile of clean paint brushes">
<h3>Hacksaw Brushes</h3>
<p>Made of the highest quality oak, Hacksaw brushes are known for
their weight and ability to hold paint in large amounts. Available
in different sizes. <span>Starting at $3.00 / brush.</span></p>
<h2 class="frames">Frames</h2>
<img src="./resources/frames.jpg" alt="Empty, colourful art frames">
<h3>Art Frames (Assorted)</h3>
<p>Assorted frames made of different material, including MDF, birchwood,
and PDE. Select frames can be sanded and painted according to your
needs.<span>Starting at $2.00 / frame.</span></p>