Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

css

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

Do I have to list each element type explicitly? Or can I set them all with a single statement?

like image 371
Mawg says reinstate Monica Avatar asked Aug 19 '10 06:08

Mawg says reinstate Monica


People also ask

How do I change the font for a whole page?

How to Change Font Size in HTML. To change font size in HTML, use the CSS font-size property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.

How do you apply to everything in CSS?

The * selector selects all elements. The * selector can also select all elements inside another element (See "More Examples").

How do I make all fonts the same in HTML?

You can use a <basefont> tag to set all of your text to the same size, face, and color.

How do I set the global font-family?

To set a global font family in React, set the font-family style on the html element in your index. css file and import the file in your index. js file. Global CSS should be imported in index.


2 Answers

You can use the * selector which applies to everything:

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

Note that this may be overkill for your purposes - due to the nature of CSS, styles set on parent elements are generally inherited by child elements, and thus, it's usually enough to set a font style on the body element to apply to the entire page.

body {
    font-family: Arial;
}
like image 164
Amber Avatar answered Oct 09 '22 17:10

Amber


No, generally specifying it on body is enough. That’s what the C in CSS is for: cascading. That means elements inherit the properties of their parent element. So anything under body (which should be everything) will inherit the font automatically.

body { font: 12px Helvetica, Arial, sans-serif; }
like image 20
Todd Yandell Avatar answered Oct 09 '22 16:10

Todd Yandell