DIV & SPAN
We often use different elements in HTML for styling purposes. For example, we have navigation bars, a hero
section, or cards on e-commerce websites where we see multiple elements together like an image,
description, and a button etc grouped together inside one container.
In HTML, there are different types of containers, but the most commonly used one is the
<div> element (short for division). A div itself has no visual appearance it’s just a container
element used to group or wrap up other html elements.
Example:
<div>
<img src="exampleImage.jpg" alt="">
<p>Lorem ipsum dolor sit amet.</p>
<button>Buy</button>
</div>
In this case, you will only see the content (image, text, and button) on the page. But with CSS, you can
style this div to look like a card.
Another useful container is the <span> element. Unlike div, which is used for
larger sections and div is block level element, <span> is used to group small pieces of text
inside a sentence and it is inline level element do not break the text to the next line. You can style
that part of the text separately to make it look different from the rest of the paragraph.