Firefox和<code> tags

时间:2018-10-02 09:05:16

标签: html css firefox font-size

I am generating a html documentation with sphinx-docs.

The links to functions are generated as tags inside blocks. The css font-size properties are 0.9em for both regular text and for the links. I have cleaned all other font-size properties in order to be sure of where the issue comes from.

In Firefox, the computed size for regular text is 14.4px while the blocks are 11.7px

In Internet Explorer and Chrome, everything is 14.4px

So it seems that firefox defines a different em base value for regular text and . And in order to have the same display in all browser, I have to fix font-size to pixel values, which is quite ugly.

Is this a known issue and is there a workaround other than not using at all?

1 个答案:

答案 0 :(得分:0)

The problem is discussed and precisely answered here:

Why does Firefox not honor CSS font-size for code tags wrapped in pre?

The main solution being to use a strange CSS hack:

font-family: monospace, monospace;