Where is it best to declare the font-family CSS property? On the html or body element?
html { font-family: sans-serif; } or
body { font-family: sans-serif; } I searched online, but I cant find a definitive answer.
To change the font size in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-size.
In CSS, we use the font-family property to specify the font of a text.
The <font> HTML element defines the font size, color and face for its content. Warning: Do not use this element. Use the CSS Fonts properties to style text.
Best practice is to set the font-family in the body.
body { font-family: Arial !important; } The !important is useful here so that in case you are using any other framework, your font-family does not get overridden.
You can also use the * selector.
* { font-family: Arial !important; } The *-selector means any/all elements, but will obviously be on the bottom of the property chain when it comes to overriding more specific selectors.
Note that the !important flag will render the font-style for * to be absolute, even if other selectors have been used to set the text (for example, the body or maybe a p).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With