문제

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