Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is 'font-family' not inherited in '<button>' tags automatically?

Tags:

html

css

fonts

I have noticed that in case of <button> tags, font-family is not inherited automatically; either I must specify it explicitly like:

<button style="font-family: some_style;">Button</button>  

or use inherit property like this:

<button style="font-family: inherit;">Button</button>  

However, the font-family is automatically inherited in case of other tags, the <a> tag for example.

Why do we have this issue with the <button> tags?

Here's a DEMO.

like image 474
Nikunj Madhogaria Avatar asked Oct 01 '14 11:10

Nikunj Madhogaria


People also ask

Do buttons inherit font-family?

Buttons have their own font-family, so don't inherit from the cascade unless you tell it to.

What does font-family inherit mean?

Using CSS Reset, or specifically font: inherit means that on browsers supporting the inherit value, all such elements are rendered in copy text font, unless otherwise specified in a style sheet. So this is about a particular methodology (or, as some people might say, ideology or religion) of authoring and design.

How do you get the font-family in HTML?

There are two types of font family names: family-name - The name of a font-family, like "times", "courier", "arial", etc. generic-family - The name of a generic-family, like "serif", "sans-serif", "cursive", "fantasy", "monospace".

Which attribute is used to set the font-family?

Font Type: Font type can be set by using face attribute with font tag in HTML document.


1 Answers

Form elements don't inherit font settings, you have to set these properties manually.

If you use font declaration for eg. body,

body {font-family: arial, sans-serif} 

use just

body, input, textarea, button {font-family: arial, sans-serif} 

or

input, textarea, button {font-family: inherit} 
like image 173
pavel Avatar answered Oct 10 '22 16:10

pavel