Compare width between pixel and inch measurement in HTML and CSS

Description

The following code shows how to compare width between pixel and inch measurement.

Example


<!-- w ww.  java  2 s  .c om-->






<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Pixels to Inches</title>
<style type='text/css'>
div {
background: #000;
border: 1px solid rgb(128, 128, 128);
color: white;
font: 9px monospace;
margin: 15px;
text-align: center;
}
div#inches {
width: 1in;
height: 1in;
}
div#pixels {
width: 96px;
height: 96px;
}
</style>
</head>
<body>
<div id='inches'>&lt;-- 1 Inch --&gt;</div>
<div id='pixels'>&lt;-- 96 Pixels --&gt;</div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Compare width between pixel and inch measurement in HTML and CSS