align textbox in div

Posted on 2009-02-19
Last Modified: 2012-05-06
hi there; i have a simpe <div> 25px high and 600px wide.

i want to put a textbox in there that is the exact height (25px) and 200px wide.

<div style="width:600px; height:25px; background-color:Blue;">
    <asp:TextBox ID="txtText" runat="server" style="height:25px; width:200px; font-size:100%; padding:0px; margin:0px; border:0px;" />

in firefox, this works perfectly.  in ie it leaves a 1 px space above it (see image).


thanks all.
Question by:vbnewbie01
    LVL 12

    Expert Comment

    Can you try this? Works both in IE and Firefox
    <div style="width:600px; height:25px; background-color:Blue;">
        <asp:TextBox ID="txtText" runat="server" style="height:25px; width:200px; font-size:100%; position:relative;top:-2px; margin:0px; border:0px;" />

    Open in new window

    LVL 15

    Accepted Solution

    Or just use position:absolute; in your textbox, works in both IE and Firefox.

    style="height:25px; width:200px; font-size:100%; padding:0px; margin:0px; border:0px; position:absolute;"
    LVL 1

    Author Comment

    leaning toward aibusinesssolutions and thanks to you both but can either of you explain why the space was there in the first place?
    LVL 15

    Expert Comment

    One of the biggest quirks between IE and Firefox is how they display their textboxes. Unfortunately, there is not much you can do other than customizing the styles to get them close.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now