+ 3

# or .

For CSS, I am unsure when to use . and #. Could someone explain the difference please?

4th Jul 2019, 2:48 PM
Steffen Wilkinson
2 Answers
+ 4
Sure # = id . = class We generally use id for single, unique items on our page (titles for example) class however is used for multiple items. Here's an example: <style> /* this will target your ID myTitle */ #myTitle { color: blue; font-size: 20px; text-align: center; } .redbox{ /* this will target your classes */ width: 250px; height: 100px; background-color: red; } </style> <body> <h1 id="myTitle"> Hello SoloLearn </h1> <p>List of boxes below</p> <div class="redbox"> box 1 </div> <div class="redbox"> box 2 </div> <div class="redbox"> box 3 </div> </body>
4th Jul 2019, 3:14 PM
HNNX 🐿
HNNX 🐿 - avatar
+ 1
Thanks!
9th Jul 2019, 4:55 PM
Steffen Wilkinson