How to use CSS class selector .class

Description

The .class selector adds style for all elements with the specified class.

Example


<!DOCTYPE html>
<html>
<head>
<style>
.grayStyle<!--   w  ww  .  j  a  v a  2 s .  c  o  m-->
{ 
    background:#eee;
}
</style>
</head>

<body>
   <p class="grayStyle">java2s.com.</p>
</body>
</html>

Click to view the demo

The code above generates the following result.

.class




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference