What is the purpose of using font: inherit?

前端 未结 7 920
醉酒成梦
醉酒成梦 2020-12-25 10:16

I just wanted to know why font: inherit; is used in Cascading Style Sheets.

7条回答
  •  一生所求
    2020-12-25 10:55

    Not all browsers inherit font properties on all elements. Netscape 4.x was notoriously bad about about inheritance. Consider the following style:

    body { background: black; color: white }
    

    In Netscape 4.x, the color was not applied to table elements, so you would end up with the default black text inside the table on a black background.

    Font properties have the same kind of deal for some elements, particularly form elements (and table elements for older browsers). It's not uncommon to see a definition like this:

    table, form { font: inherit }
    

提交回复
热议问题