Click to See Complete Forum and Search --> : 1 pixel div


piramyd
03-01-2009, 03:38 PM
i have this css:

div{
font-size:1px;
width:1px;
height:1px;
background-color:#3355ff;
}

on this html:

<div></div>.



My problem is that on IE it makes a 1 by 2 pixels div. Not less. Now you probably think: why do i need font-size:1px inside the div. Well it's because IE keeps the size of the div bigger than the size of the text... I figured. So can anybody pls help me make a 1x1 px div? Or at least tell me a way to paint only a pixel of a div, and then find out what color is a specific pixel in that div..

10x a lot!!

coothead
03-01-2009, 07:04 PM
Hi there piramyd,

and a warm welcome to these forums. ;)

IE7 will display a 1px by 1px div if the document has a full dtd.
IE6 will not play ball at all with the div but will show a 1px by 1px border as this example will show...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">

<title></title>

<style type="text/css">
div{
font-size:1px;
width:1px;
height:1px;
background-color:#35f;
}
</style>

<!--[if IE 6]>
<style type="text/css">
div{
background-color:transparent;
border-bottom:1px solid #35f;
}
</style>
<![endif]-->

</head>
<body>

<div></div>

</body>
</html>

coothead