+ 1

Can't change one specific div in a list ?

Hello, I have a list of several div (10). i gave them the exact same configuration with a class. And then proceded to give each one a unique id. Now my problem is that everything works until i try to select one of the div and change it with CSS. here's the html part : <div id='menu'> <div id="firstlist"> <ul> <li><div id='1b' class='ch'></div></li> <li><div id='2b' class='ch'></div></li> <li><div id='3b' class='ch'></div></li> <li><div id='4b' class='ch'></div></li> <li><div id='5b' class='ch'></div></li> </ul> </div> <div id='secondlist'> <ul> <li><div id='6b' class='ch'></div></li> <li><div id='7b' class='ch'></div></li> <li><div id='8b' class='ch'></div></li> <li><div id='9b' class='ch'></div></li> <li><div id='10b' class='ch'></div></li> </ul> </div> </div> And here's the CSS part : #1b{ background-color: red; } #menu{ display: flex; } #menu ul{ display: flex; flex-direction: column; } .ch{ border: 1px solid black; border-radius: 100%; height: 60px; width: 60px; transition-duration: 0.5s; list-style: none; margin: 8px; } .ch:hover{ transition-duration: 0.5s; width: 70px; height: 70px; } .ch:active{ transition-duration: 0.5s; border-bottom-color: red; } a HUGE thanks to anyone that can help !!! Have a great day !

16th Jun 2022, 6:14 PM
Sumpheus
Sumpheus - avatar
5 ответов
+ 5
The problem seems to be that the id should no start with a digit… Html: <div id=b1>Text</div> Css: #b1{…} ^^Worked for me While it did not work with id 1b
16th Jun 2022, 7:18 PM
Alexander Thiem
Alexander Thiem - avatar
+ 5
What do you want to change? People are more likely to help if you provide a minimal working example as a script on sololearn playground. Goo Code section, click +, select the programming language, insert your code and save. Come back to this thread, click +, Insert Code, sort for My Code Bits, select your code.
16th Jun 2022, 6:21 PM
Lisa
Lisa - avatar
+ 3
Thanks a lot, didn't even thought about that 😅🤦‍♂️. Have a Great day/night 😉👍
17th Jun 2022, 9:06 AM
Sumpheus
Sumpheus - avatar
+ 2
What Alexander Thiem said, and from the CSS course on Sololearn: "To select elements with a specific class, use a period character, followed by the name of the class. Do NOT start a class or id name with a number!"
16th Jun 2022, 7:38 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
ID's Cannot Start With a Number
16th Jun 2022, 8:21 PM
Chris Coder
Chris Coder - avatar