Why are CSS-styles not inherited by HTML form fields?

前端 未结 4 694
挽巷
挽巷 2020-12-03 23:42

I want to set the font-style and font-size of the text in my HTML document.



    Style inheritance
    &l         


        
4条回答
  •  余生分开走
    2020-12-04 00:04

    An element inherits a property only when no style sheet sets that property on the element (or when the value inherit has been set). Form fields generally have settings for them in browser style sheets.

    So you need to explicitly set properties on them to override the browser defaults. You can do this with the universal selector * if you want all elements to have some properties, e.g.

    * { font: 100% Calibri, sans-serif; }
    

    You can easily override this for specific elements when desired, since the universal selector has very low specificity.

提交回复
热议问题