Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: IE: Right padding in input text box

Go to http://jsfiddle.net/srLQH/ and fill in the input text box in the "Result" view.

If you do this in FF, Chrome, and Safari, your text will stop 20px short of the right side.

In IE 7/8, the text does not stop 20px short--it goes all the way to the edge of the input box.

What's the deal with IE? How can I get the same padding effect in IE that all the other browsers give me?

like image 794
SnickersAreMyFave Avatar asked Sep 22 '10 00:09

SnickersAreMyFave


People also ask

How do you add padding to a text box in HTML?

you can solve this, taking the input tag inside a div , then put the padding property on div tag. This work's for me...

What does padding-right do?

The padding-right property sets the right padding (space) of an element.

How do you put a space between two input boxes in HTML?

The break tag is meant for single line breaks, and not more than one in a row. If you want to add extra whitespace between pieces of text, use CSS padding and margins instead for cleaner code. Or, you can use an HTML <p> tag, as we'll see next.


2 Answers

I have been looking for a way to solve this. A colleague found a solution and we tested it and it works perfectly. So the thing is to remove the padding: right and add a border: 20px solid transparent.

like image 52
Monica Avatar answered Sep 22 '22 16:09

Monica


I've found one way of doing it, but its not pretty.

http://jsfiddle.net/dmitrytorba/dZyzr/162/

<!--[if IE]>
<style type="text/css">
input {
  border: none;
  margin: 5px;
  padding-right: 0px;
}
.wrapper {
    border: 1px #aaa inset;
}
.spacer{
    margin-left: 20px;
}
</style>
<![endif]-->


<span class='wrapper'>
    <input type='text' />
    <span class='spacer'></span>
</span>​
like image 39
Dmitry Torba Avatar answered Sep 22 '22 16:09

Dmitry Torba