Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply !important to font-family with more than one option

Tags:

css

How can I apply !important to the following syle:

font-family: "Trebuchet MS" , Verdana, Helvetica, Sans-Serif;  

I've tried this, but doesn't work:

font-family: "Trebuchet MS" , Verdana, Helvetica, Sans-Serif !important;
like image 976
Rauland Avatar asked May 09 '12 21:05

Rauland


People also ask

How do I use multiple font families in HTML?

Start with the font you want, and always end with a generic family, to let the browser pick a similar font in the generic family, if no other fonts are available. Note: Separate each value with a comma. Note: If a font name contains white-space, it must be quoted.

What are the two font families?

Font Families: Serif, Sans-serif, and others In CSS (and in typography in general) there are five basic types, or families, of fonts: serif, sans serif, cursive, fantasy, and monospace. Serif fonts have small lines or strokes that extend from the ends of characters.

What is the purpose of listing multiple font families in a style?

Not all browsers support all the fonts. So, giving multiple font families select the font that is supported by the browser, starting from the first font. If first font is supported then it is used, otherwise it checks if next font is supported and so on.


2 Answers

Select the children within the parent container with a wildcard (*):

div * {font-family: "Trebuchet MS" , Verdana, Helvetica, Sans-Serif !important; }

http://jsfiddle.net/4d3K4/50/

like image 141
daleyjem Avatar answered Oct 01 '22 23:10

daleyjem


The code is fine. It would vary depending on which elements you are giving the property to. It's better if you use specific selectors such as classes:

http://jsfiddle.net/4d3K4/

like image 36
Yisela Avatar answered Oct 02 '22 01:10

Yisela