How to apply the same font to everything on the page?

Let's say that I want to specify Arial in the HTML header - and I want it to apply to everything.

Does each element type need to be explicitly specified? Or can I install them all with one statement?

+4
source share
3 answers

You can use the selector * , which applies to everything:

 <style> * { font-family: Arial; } </style> 

Please note that this may be redundant for your purposes - due to the nature of the CSS, the styles set on the parent elements are usually inherited by the child elements, and as a rule, this is enough to set the font style in the body element to apply to the whole page.

 body { font-family: Arial; } 
+19
source

No, usually pointing it to body enough. Here's what C is in CSS: cascading. This means that elements inherit the properties of their parent element. So, everything under the body (which should be everything) inherits the font automatically.

 body { font: 12px Helvetica, Arial, sans-serif; } 
+2
source

I prefer

 body { font-family: Arial; } 

and let him cascade down. This has the advantage of not rushing into the explicit selection of fonts further down the tree. If you want to stomp, use the form * in other answers

+1
source

All Articles