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?
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?
Try this:
Use the following css:
The
*
-selector means any/all elements, but will obviously be on the bottom of the food chain when it comes to overriding more specific selectors.Note that the
!important
-flag will render thefont
-style for*
to be absolute, even if other selectors have been used to set the text (for example, thebody
or maybe ap
).Best practice I think is to set the font to the body:
and if you decide to change it for some element it could be easily overwrited:
You should never use
* + !important
. What if you want to change font in some parts your HTML document? You should always use body without important. Use!important
only if there is no other option.Set it in the body selector of your css. E.g.
You should be able to utilize the asterisk and
!important
elements within CSS.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.