3

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;
}
user779159
  • 9,034
  • 14
  • 59
  • 89
  • It seems that input and textarea using different font family. That mean that the font size itself wont help. https://stackoverflow.com/questions/20013784/what-is-default-font-style-of-textarea-in-chrome-text-input-vs-textarea-size – A. Meshu Oct 07 '18 at 15:50

5 Answers5

1

add font-size in both input, textarea

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

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*/
}
Chris Josh
  • 389
  • 3
  • 7
0

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

Mr. Hugo
  • 11,887
  • 3
  • 42
  • 60
  • Tried that in the jsfiddle, it doesn't work. And even so I want them to get the values that have been set for the whole document rather than having to duplicate the font-size value for these elements which have already been defined on `body`. – user779159 Oct 07 '18 at 15:29
  • It works (see jsfiddle). Please change your question if you have a different question (or ask a new one). – Mr. Hugo Oct 07 '18 at 15:39
  • I'm using chrome on linux and the input text is still larger than the textarea text for me. – user779159 Oct 07 '18 at 15:45
  • Font-size is the same... font-family is not. If you explicitly set the font-family the same too (not inherit them), the fonts will be identical. – Mr. Hugo Oct 07 '18 at 15:52
0

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.

0

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.

Poul Bak
  • 10,450
  • 5
  • 32
  • 57