Sweety Sweety - 10 months ago 54
CSS Question

How to Apply global font to whole HTML document

I have a HTML page which includes some text and formatting. I want to make it have the same font-family and the same text-size ignoring all inner formatting of text.

I want to set a global font format for the HTML page.

How can I achieve this?


You should be able to utilize the asterisk and !important elements within CSS.

html *
   font-size: 1em !important;
   color: #000 !important;
   font-family: Arial !important;

The asterisk matches everything (you could probably get away without the html too).

The !important ensures that nothing can override what you've set in this style (unless it is also important). (this is to help with your requirement that it should "ignore inner formatting of text" - which I took to mean that other styles could not overwrite these)

The rest of the style within the braces is just like any other styling and you can do whatever you'd like to in there. I chose to change the font size, color and family as an example.