Set width to 1in in HTML and CSS

Description

The following code shows how to set width to 1in.

Example


<!--from  w w w . j a va  2s  .  co m-->






<html>
<head>
<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.

Set width to 1in in HTML and CSS