How to Make Buttons and Text Boxes Use the Page's Font with font: inherit in CSS
Text boxes and buttons don't use the page's font: Chromium draws them in its own 13.33-pixel text, whatever you set on body. One rule, font: inherit, makes them take the font of the element they sit in.
Syntax
<form controls> {
font: inherit;
}
| Part | What it does |
|---|---|
<form controls> | The elements that should use the page's font, as a selector list: button, input, select and textarea. |
font | The shorthand that sets every font property at once: the family, the size, the weight and the rest. |
inherit | Takes each value from the parent element. |
MDN's font page explains the shorthand, and its guide to styling web forms notes that some form controls don't inherit font-family and font-size from their parents by default.
The Example
The example is a search box and a button under a line of text, on a page set to 18-pixel Arial. First you see the box and the button keep their own small text, then one rule makes them match.
Step 1: Write the Code
Create a file named index.html in a text editor, such as Visual Studio Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>font: inherit</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
}
</style>
</head>
<body>
<p>Search the menu:</p>
<p><input value="Coffee"> <button type="button">Search</button></p>
</body>
</html>
The body rule sets the font for the page: Arial, at 18 pixels.
Step 2: Open It in a Browser
Double-click index.html. It opens in your browser:

The text in the box and on the button is smaller than the line above it: Chromium gave them 13.33 pixels, while the paragraph has 18. The screenshot comes from Chromium 159, the open-source browser that Chrome is built on.
Step 3: Add font: inherit
Add a rule for button and input to the style element, so the file looks like this:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>font: inherit</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
}
button,
input {
font: inherit;
}
</style>
</head>
<body>
<p>Search the menu:</p>
<p><input value="Coffee"> <button type="button">Search</button></p>
</body>
</html>
Step 4: Reload the Page
Save the file and reload the page in your browser:

What Happened
- Before the rule, the box and the button were 13.33 pixels, Chromium's own size for form controls, although the page was set to 18.
- After it, both are 18 pixels in the page's Arial stack.
font: inherittook every font value from the paragraph they sit in, which got its font frombody. - The box and the button grew to fit the bigger text.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Using only font-family: inherit | Only the family follows the page: the text box stayed 13.33 pixels | Use font: inherit, which covers the size too |
Leaving out select and textarea | They keep their own fonts too: Chromium gave a textarea 13.33-pixel monospace text, and a select 13.33 pixels | List all four: button, input, select, textarea |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Form controls have smaller text than the page | They don't inherit the font by default | Add font: inherit to them |
| A text area is in a typewriter-like font | Chromium draws text areas in monospace | Include textarea in the rule |
FAQ
Does it work for text areas and drop-down lists too?
Yes. With button, input, select, textarea { font: inherit; }, a textarea and a select both came out in the page's 18-pixel Arial.
Why font and not font-family?
font: inherit brings the family, the size and the weight in one line. font-family: inherit on its own changed only the family, and left the text box at 13.33 pixels.
Conclusion
Form controls keep their own font unless you tell them otherwise. One rule, button, input, select, textarea { font: inherit; }, makes them follow the page.
Additional Resources
- font, on MDN.
- Styling web forms, on MDN.
