Pixels

Description

The mainstream browsers treat 1 pixel to be 1/96th of an inch.

Example

The following code shows demonstrates specifying pixels in a CSS style.


<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
p  {<!--  w w  w.ja v a2s  .co  m-->
    background: grey;
    color:white;
    font-size:  20px;
    width:  200px;
}
</style>
</head>
<body>
   <p>This is a test.</p>

</body>
</html>

Click to view the demo

Note

em units are more flexible. You only have to alter the size of the font and the rest of the style works seamlessly.





















Home »
  HTML CSS »
    CSS »




CSS Introduction
CSS Background
CSS Border
CSS Box Layout
CSS Text
CSS Font
CSS Form
CSS List
CSS Selectors
CSS Others
CSS Table