How to use CSS id Selector #id

Description

The #id selector adds style the element with the specified id.

Example


<!DOCTYPE html>
<html>
<head>
<style>
#grayStyle<!--from   w  w w  .  j  a v  a 2  s .c  om-->
{
    background-color:#eee;
}
</style>
</head>
<body>
   <p id="grayStyle">java2s.com.</p>
</body>
</html>

Click to view the demo

The code above generates the following result.

#id




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference