Вопрос

I'm going to define a font-family to be used for the entire page (unless specifically modified by a lower element/id/class), and I was wondering whether its better practice (or more common) to designate the font-family for the html tag or the body tag?

The property should automatically be inherited to all the content that I can think of regardless of I designated it in html or body, so I wonder if it even matters? I noticed Google and Wikipedia both designate the font-family for BOTH the html and body elements, so I'm curious as to what the advantages of defining font-family for either/both of the elements.

If you could point out cases in which either tag would be preferable, that'd be excellent.

Это было полезно?

Решение

It is more common to set font properties on the body element than on the html element. Normally, it doesn’t really matter.

Setting them on the html element lets any other style sheet override your font settings by just setting their font settings on body. This might sometimes be desirable.

It would also matter in the rare cases where you make some elements in the head part visible, with CSS, against their default setting of display: none.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top