2

html{
	font-size:62.5%;
}

body{
	font-family:arial;
	font-size:1.1rem;
}
<p>LOREM IPSUM</p>
<p>LOREM IPSUM</p>

<input type = 'text' value = 'LOREM IPSUM'>

Why doesn’t font-size:1.1rem work inside input-fields?

How to get a global font-size for the entire page?

3
  • Your font size is equal in the input, but it sounds like you want it to be 1.1rem, is that right? Just add input { font-size: 1.1rem; } Commented Aug 12, 2018 at 13:17
  • @duhaime, why specifying font-size for body is not enough? Commented Aug 12, 2018 at 13:18
  • 2
    check this out: stackoverflow.com/questions/6080413/… Commented Aug 12, 2018 at 13:20

2 Answers 2

5

It's because the input already have font-size defined by the user agent unlike p element so the p element will inherit the value defined by the body and input will use its own value unless you override it:

enter image description here

So the input element will have the computed value of font-size like follow:

enter image description here

As you can see, the font of the body is considered BUT it's overridden by the one already defined by default.

Sign up to request clarification or add additional context in comments.

Comments

1

The input fields are not effected by font variations you make for the body element. You have to style them separately.

To change that, use

input[type=text] {
    font-size: inherit;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.