Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default textbox border-style and width

IE7 and FFox seem to render textboxes very slightly differently by default.

This seems to be fixed by setting their border-style and border-width css properties.

The odd thing is, it seems that out of all the options vstudios intellisense gives me, none of them match?

The closest I've found is

border-width:1px;
border-style:inset;

Edit: Trying to set the style for a textbox, they all appear to render differently in various browsers.

like image 698
maxp Avatar asked Aug 05 '09 09:08

maxp


3 Answers

According to Firebug, the default style for a textbox in Firefox is

border: 2px inset #EBE9ED;
like image 124
Amber Avatar answered Oct 21 '22 03:10

Amber


This is the first question/result that comes up via Google when looking for this sort of thing, so I thought I'd provide the answer I was looking for personally.

the answer is to set the style to '' or "";

If this is unclear, I am providing an example involving javascript/jquery, assuming you get that at a basic level. Naturally, the box starts off at a default. Let's assume I change it with code to be red, when someone clicks on that textbox...

$("#phoneBox").focus(function(){
       document.getElementById('telephone').style.border = '1px solid red';
       }

That will set it to red someone clicks into that textbox. Now, however, let's assume I want to set it back to normal when someone clicks away from the box

$("#phoneBox").blur(function(){
       document.getElementById('telephone').style.border = '';
       }

The box will go back to the default style, since it has no values to go off of.

In your CSS, just

border:'';

or to be thorough,

border-style:'';
border-width:'';
border-color:'';

will render the default in any browser. I hope that this makes sense/helps others.

like image 38
Xagrand Avatar answered Oct 21 '22 04:10

Xagrand


Maybe you will not believe me, but I try this:

<input style="border:default">

and it works in Windows Internet Explorer 8, Firefox 3.6.22 and Chrome 14.0.835

I think <input style="border:XXX"> <input style="border:XXX"> works too. The point is that if you use an invalid border style, then the input box goes back to its default border style.

like image 38
Ing Óscar Bonilla MBA Avatar answered Oct 21 '22 03:10

Ing Óscar Bonilla MBA