-
Hi all! I have a question about css selectors: I like serif fonts, so I'd started to write a custom style which changes every fonts on every webpage to serif. However there are some exceptions, notably:
I can override all fonts like this: body :not(code):not(pre) {font-family: serif !important;} but what should really there is to set font to serif for all places except Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Since I also prefer serif fonts, I made the following userstyle for my own use. It uses Stylus-lang preprocessor in order for code to be more documented, extendable, and maintainable in the long run. /* ==UserStyle==
@name Global serif font
@namespace www
@version 1.0.0
@description Apply your favorite serif font globally.
@author vednoc
@preprocessor stylus
@var text font 'Serif font' '"your favorite serif font"'
==/UserStyle== */
@-moz-document regexp("https?://.*") {
i = !important
// Exclude default code areas.
n ?= ':not(code):not(pre):not(pre > span):not(code > span)'
// Exclude icon fonts.
n += ':not([class^="fa"]):not(.i)'
// Exclude code areas on GitHub.
n += ':not([class^="blob-"]):not([class^="blob-"] > span)'
// Exclude code areas on GitLab.
n += ':not(.diff-line-num):not(pre > code > span span)'
// Exclude utility classes for fonts.
n += ':not(.monospace):not(.text-mono)'
// Generate.
{ n } {
font-family: font, serif i
}
} For more information, check wiki pages on how to install it and then customize it if you've never used UserCSS format until now.
As far as I know, this is the only way to do it. :not(pre):not(pre *):not(code):not(code *) { ... } |
Beta Was this translation helpful? Give feedback.
Since I also prefer serif fonts, I made the following userstyle for my own use. It uses Stylus-lang preprocessor in order for code to be more documented, extendable, and maintainable in the long run.