DEV Community

Rajat Gupta
Rajat Gupta

Posted on

CSS: Importance of <div></div>

Whenever I wanted to build CSS for an HTML page, I used to use random CSS properties just to get my work done but there is no structure to it and as a result whenever I come back to it, I was lost. If this sounds familiar, read on.

There is a simple yet effective solution to tackle the above problem: start using divs.
Let me explain: Get into the habit of dividing every HTML page into sub-sections called divs and then apply css properties to these divs. for example let's say you wanna make the below page:

Alt Text

How many divs do you think the above page has, yes! you guessed it right, the page has 7 divs. Now we can either apply CSS properties such as color, background-color, font-size, padding, text-align etc to these divs individually or in a group by using id or class respectively. The property will be automatically applied to all the elements present in that particular div container and as a result it becomes much easier to design the whole webpage.

Discussion (0)