+ 3

Use period or pound?

when styling element in css use period or pound? what is difference of . or #?

17th Jun 2018, 5:38 PM
Joshua Morgan
Joshua Morgan - avatar
3 ответов
+ 3
# is for styling elements targeted by their assigned id. . is for styling by their assigned class. Elements can have multiple classes but only one id.
17th Jun 2018, 5:40 PM
Andre Daniel
Andre Daniel - avatar
+ 3
# is for id and .(dot) is for class for example <html> <head> <title> id and class </title> <style> .container{ width:110px; height:100px; background-color:green; } #box{ width:100px; height:40px; background-color:red; } </style> </head> <body> <div class="container"> <div id="box"></div> <div id="box"></div> </div> </body> </html> the output is: there are two red boxes within a green container. in this sample div structure is very important. because right after coding div structure, you have to apply css attributes to your div structure.
18th Jun 2018, 9:04 AM
Andrew Ting Mai Zau
Andrew Ting Mai Zau - avatar