Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I apply a font type to everything using css

Tags:

css

Basically, I need to adjust the font type everywhere it isn't specified. How can I do that? table, div, span, p, input, you name it. Is there a way I can do them all with 1 CSS rule that I can add?

like image 652
Refiking Avatar asked Aug 12 '10 04:08

Refiking


2 Answers

Yes there is, use it on the body element and it will cascade down to all children unless you specify otherwise.

body {
    font-family: Arial, Verdana, sans-serif;
}
#tahoma {
    font-family: Tahoma, sans-serif;
}

You can then override it

<body>
  <div id="default">
    I will inherit the body font-family, in this case Arial because no other rule has been set!
  </div> 
  <div id="tahoma">
    <p>Me, <span>Me</span> and <strong>Me</strong> are using Tahoma because our parent #tahoma says so.</p>
  </div>
</body>
like image 162
Marko Avatar answered Oct 13 '22 20:10

Marko


This is why it's called Cascading Style Sheets. Styles set at any level will "cascade" down. So if you set this styling on the body element, every other element in the body will take on the same styles.

body {
    font: ...;
}
like image 39
jtbandes Avatar answered Oct 13 '22 20:10

jtbandes