Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change input text border color without changing its height

Tags:

html

css

border

Let's say I have a default text input without any CSS

<input type="text" />

I want to change its border color to red so I add an style

<input type="text" style="border-color:red" />

After that the border is red, but its size is 2px. If I change the border to 1px the height of the input will be smaller than a default one.

How can I change my border to 1px and assure that the true height of the input (including the border) is the same as an default one?

like image 826
user937450 Avatar asked Mar 14 '13 08:03

user937450


People also ask

How do you put a border on a input box?

Textboxes are input fields created by the <textarea> element. You can use the CSS border property to add a border around your HTML textboxes. You can also use border-width , border-style , and border-color , but the border property covers all of these anyway.


2 Answers

Try this

<input type="text"/>

It will display same in all cross browser like mozilla, chrome and internet explorer.

<style>
    input{
       border:2px solid #FF0000;
    }
</style>

Dont add style inline because its not good practise, use class to add style for your input box.

like image 34
Devang Rathod Avatar answered Sep 22 '22 03:09

Devang Rathod


use this, it won't effect height:

<input type="text" style="border:1px solid #ff0000" />
like image 87
Atif Azad Avatar answered Sep 22 '22 03:09

Atif Azad