How to use CSS-Classes? (Cascading Style Sheets)?
I have oft seen classes like this "#classname" and ".classname" but what's the difference? How to use them properly?
Public Comments
- You are referring to selectors. The . (period) prefix denotes a class. That is, .classname will apply to all elements that have the attribute class="classname". # refers to the ID. So it is not really #classname, but rather #elementID. It refers to one (and one only) specific element, with an attribute id="elementID".
- "#" used for advanced clasee, and "." for others... you can set the position of a <Div> in page with "#" advanced classes. example: <html> <title>CSS</title> <style type="text/css"> #leftPan { background-color: #CCCCCC; float: left; height: 120px; width: 80px; border-top-color: #333333; border-right-color: #333333; border-bottom-color: #333333; border-left-color: #333333; margin-left: 30px; bottom: 10px; } .text{ font-family: Tahoma; font-size: 10px; padding: 2px; border-bottom-color: #333333; border-bottom-style: solid; border-bottom-width: thin; } </style> </head> <body> <div id="leftPan"> <div class="text"> CSS CLASS </div> </div> </body> </html>
Powered by Yahoo! Answers