+ 1

When to use Div id and div class?

What are their difference?? can anyone explain much further.

5th Jul 2016, 9:38 AM
Brian Andre Garcia
Brian Andre Garcia - avatar
2 Respuestas
+ 1
If you want to apply a certain (same) style to many different elements, use 'class'. Otherwise, when you have a unique style that you want to give to just ONE element, use 'id'. <head> <style> #wrapper { width: 80%; margin: 0 auto; } .green { color: green; } </style> </head> <body> <div id="wrapper"> <h1>Some Heading</h1> <p>Lorem ipsum <span class="green">dolor</span> sit amet, consectetur adipiscing elit, sed do eiusmod <span class="green">tempor</span> incididunt ut labore et dolore magna aliqua.</p> </div> </body>
5th Jul 2016, 2:27 PM
ZinC
ZinC - avatar
0
Class if for many, ID for one. Think that there are many kids in a 'class', but you can IDentify a single kid by their name.
11th Jul 2016, 4:02 PM
Hannah T
Hannah T - avatar