Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


make same size of textbox and TD

Posted on 2011-09-15
Medium Priority
Last Modified: 2012-05-12
Id liek the textbox size same as the width and height  of teh TD. How is taht done in HTML or CSS?
Question by:zachvaldez
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 38

Expert Comment

by:Tom Beck
ID: 36543394
<td style="width:300px;height:75px"><input type="text" style="width:100%;height:100%" /></td>

The textbox will fill the 300 x 75 pixel TD, textbox borders will overflow however.
LVL 38

Expert Comment

by:Tom Beck
ID: 36543501
Does not work in IE8 Compatibility mode.
LVL 38

Expert Comment

by:Tom Beck
ID: 36543714
As a workaround for IE8 Compatibility mode, you could use a little javascript to adjust the textbox or textarea height to match the height of the td. The width is not a problem except for the overflowing border which you can fix by making the width 98% instead of 100. For example:

<style type="text/css">
#txtBox {width:98%; height:100%}
#txtBox1 {width:98%; height:100%; overflow:hidden}

<td id="txtTd" style="width:300px;height:75px"><input type="text" id="txtBox" /></td>
 <td id="txtTd1" style="width:300px;height:75px"><textarea id="txtBox1"></textarea></td>

<script type="text/javascript" language="javascript">
document.getElementById('txtBox').style.height = document.getElementById('txtTd').style.height;
document.getElementById('txtBox1').style.height = document.getElementById('txtTd1').style.height;
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 25

Expert Comment

by:Kyle Hamilton
ID: 36546428
You could always add box-sizing:border-box; for the input style. IE's box model does this automatically. This way you get your borders inside the box in all other browsers - no need for percentages.


Author Comment

ID: 36546523
Maybe I'm bothered with the borders of the textbox.can u add a css that when a textbox or label are use the borders would Nott that obvious .It doesn't look good with the td background space inside a table cell.
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 36546601
I'm not sure I understand the concern.

Can you also post a link to your page? And a screenshot of what you would like it to look like...
LVL 38

Accepted Solution

Tom Beck earned 800 total points
ID: 36547042
You can style the borders on the textboxes however you like:

Wide gray border:

#txtBox {width:98%; height:100%; border:solid 3px #ddd}
#txtBox1 {width:98%; height:100%; overflow:hidden; border:solid 3px #ddd}

No border:

#txtBox {width:98%; height:100%; border:0}
#txtBox1 {width:98%; height:100%; overflow:hidden; border:0}

You could also play with the borders on the TDs.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

610 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