CSS Selector - How to use CSS element Selector








The element selector adds style to all elements with the specified element name.

Examples:

body  {background:  #FFF;}
p  {font-size: 1em;}

Summary

CSS Version
2

CSS Syntax

element { 
   style properties 
}




Browser compatibility

element Yes Yes Yes Yes Yes

Example

An example showing how to use element CSS selector

<!DOCTYPE html>
<html>
<head>
<style>
p{<!-- w w  w  .j a  va 2  s  .co  m-->
    background-color:red;
}
</style>
</head>
<body>
   <p>java2s.com.</p>
</body>
</html>

Click to view the demo