Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between "." and "#" selector in CSS
'.' selector
'.' selector is a class level selector. The dot operator is used to create a style class which can then be applied on multiple html elements.
'#' selector
'#' selector is an element level selector. Hash operator is used to applying style on a particular element whose id is the same as used in '#' selector
Example
Following the example, shows usage of '.' as well as '#' selector on three div elements.
<!DOCTYPE html>
<html>
<head>
<title>Selector Example>/title>
<style>
.blackBorder {
border: 2px solid black;
}
#redDiv {
border: 2px solid red;
}
</style>
</head>
<body>
<div> No Border Box </div>
<div class="blackBorder"> Black Border Box </div>
<div id="redDiv"> Red Border Box </div>
<div> No Border Box </div>
<div class="blackBorder"> Black Border Box </div>
</body>
</html>Advertisements