user779159
user779159

Reputation: 9602

How to make font size in textarea same as input field in CSS?

The font size in the textarea in https://jsfiddle.net/Ljxwre2y/ is smaller than in the input field, how can I make them both the same size?

body {
  font-family: 'Montserrat';
  font-size: 30px;
}

input,textarea {
  margin: 0;
  padding: 0;
  width: 100%;
}

textarea {
  font-family: inherit;
}

Upvotes: 3

Views: 5322

Answers (5)

Chris Josh
Chris Josh

Reputation: 475

This is what I usually do, always works for me.

in your body tag, specify font-family and others... like font-size.

html,
body {
    height: 100%;
    font-family: 'Source Sans Pro', monospace;
}

then, inherit...

textarea,
input,
select {
    font-size: inherit;
    font-weight: inherit;
    text-decoration: none;
    font-family: inherit;
    color: #19272D; /*your input color*/
}

Upvotes: 1

Poul Bak
Poul Bak

Reputation: 10929

You can use the '*' selector to set fonts, size and Family, then it will apply to all elements on the page, like this:

* 
{
    font-size: 14px;
    font-Family: Arial;
}

Add this as the first entry in your css.

Upvotes: 0

Mr. Hugo
Mr. Hugo

Reputation: 12592

You have to explicitly set them in CSS to prevent the browser from using the browser defaults. Like this:

input, textarea {font-size: 14px;}

See jsfiddle

input, textarea {font-size: 14px; font-family: sans-serif;}

Use the above code to make the fonts exactly the same (so not only the size). See jsfiddle

Upvotes: 0

user9255534
user9255534

Reputation:

Try this:

input, textarea {
    margin: 0;
    padding: 0;
    width: 100%;
    font-family: "Monsterrat";
    font-size: 30px;
}

Both input and textarea doesn't inherit font family. So you need to set font-family property to either your font name or inherit keyword.

Upvotes: 0

Dibyendu Ghosh
Dibyendu Ghosh

Reputation: 15

add font-size in both input, textarea

input,textarea{
font-size: 30px;
}

Upvotes: 1

Related Questions