www.webdeveloper.com
Results 1 to 2 of 2

Thread: 1 pixel div

  1. #1
    Join Date
    Mar 2009
    Posts
    1

    1 pixel div

    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!!

  2. #2
    Join Date
    Jan 2004
    Location
    chertsey, a small town s.w. of london, england.
    Posts
    1,450
    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...
    Code:
    
    <!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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles