Difference b//w div and class in CSS

+2 Tushar A · March 8, 2015
Hello , 

Can you help me out with the differences b/w div and class in CSS. I mean they are both used for the same purpose? Using classes I can apply a particular effect to 1 of the 8 paras as in tne tutorial wheres in the case of div I can position the things wherever I want? I mean does the div attribute does not support color , font-weight ,etc? so that we could actually eliminate the use of classes altogether?

Post a Reply


Oldest  Newest  Rating
0 Roman Smirnov · March 8, 2015
A div is just a container, a class describes what kind of container the div is and what properties the stuff inside will have.
As an example, for a standard site built using a grid system:


what you see are two divs, one is a column and on is a  row.

lorem ipsum

in this example the class .text-center aligns all the text inside the column div to the center
  • 1

HTML / CSS / Web Design


Discuss, share, ask, learn and teach HTML5 and CSS3.