#Body vs Heading Fonts
208 messages · Page 1 of 1 (latest)
I don't think that's how you import fonts from Google Fonts
Those font URLs don't point to fonts, they point to plain CSS files
Can you link to the wiki
Uh every time I do it says people can't access it because its private
this page should be whitelisted
The issue I'm having is then
1. Apparently I don't know what embed/import code to use from Google Fonts
2. I don't know how to refer to each level of font (body, heading 1, heading 2, etc.) in the common.css
Just use @import url("https://fonts.googleapis.com/css?family=Lora|Nunito&display=swap"); instead of those font-face declarations
So you can import multiple within the same font-face?
just separate them with a pipe?
You can't use @font-face you have to use @import
Yeah idk why css2 doesn't let you import multiple or even what's the difference
Like the output CSS looks the same
Hmm okay I have changed that but don't see any difference using ?debug=2 on my testing page, or in css common
do the mw-body content bits need changing
Oh nvm css2 supports multiple actually https://fonts.googleapis.com/css?family=Lora&family=Nunito&display=swap
But anyways
@import url("https://fonts.googleapis.com/css?family=Lora|Nunito&display=swap");
}
.mw-body-content .firstheading {
font-family: 'Lora', Serif;
}
.mw-body-content .body {
font-family: 'Nunito', Sans-Serif;
}
oh, the capitalisation matters?
is .body a class?
I couldn't see anyone use it when I searched previous comments here, only ever saw headings
so it's a guess
Yeah .body is not a class that I know of
Do you know what the class for body text would be?
You can just use .mw-body-content
https://river.me/blog/dev-tools/ You should read this blog post to help you find CSS selectors in the future
:root {
--font-family-citizen-base: Nunito, sans-serif;
}
Hm okay I have changed it to that, but it doesn't seem to recognise either of them
it's defaulting to whatever the usual font for citizen is
Oh yeah I forgot Citizen actually has CSS variables
this doesnt seem to do anything sorry
thank you
It does for me
/* CSS placed here will be applied to all skins */
/* FONTS */
@import url{("https://fonts.googleapis.com/css?family=Lora|Nunito&display=swap");
}
:root {
--font-family-citizen-base: Nunito, sans-serif;
}
As Kocka said
@import url("https://fonts.googleapis.com/css?family=Lora|Nunito&display=swap");
:root {
--font-family-citizen-base: Nunito, sans-serif;
}```
The code is "working" but the font is never imported because the syntax is invalid
I thought they were meant to be separate
does @import not have a curly bracket ?
No
Hm i have copied it over directly to be sure, still no dice
It works for me
But if you want to use css2 instead of css then this would be the link
https://developers.google.com/fonts/docs/css2 it's probably unimportant
@import url('https://fonts.googleapis.com/css2?family=Lora:wght@600&family=Nunito:ital@0;1&display=swap');
but it took 15 mins to even update the debug=2 disabled cache or common css pages
No yeah css2 has a different way to specify families
@import url("https://fonts.googleapis.com/css?family=Lora&family=Nunito&display=swap");
:root {
--font-family-citizen-base: Nunito, sans-serif;
}
this is what it looks like now
And it recognises the body font
Now just need to add in the heading again
Looking at other posts, would it be something like
.mw-body .firstHeading, .mw-body-content h1, .mw-body-content h2, .mw-body-content h3, .mw-body-content h4, .mw-body-content h5, .mw-body-content h6, .mw-heading1, h1, .mw-heading2, h2 {font-family: 'Lora';}
Because I don't know what it would be as the variable (?) Unai made?
The variable I posted was specifically for body text
would there be a way to make ones for the heading levels, or headings overall, or do they need to be referred to like the above
Apologies for being dense
You can use that, although I'd go for a cleaner (and safer) way with
.mw-heading, .mw-page-title-main {
font-family: Lora;
}
Citizen relies heavily on CSS variables and intends you to use them so you can quickly overwrite stuff without worrying if you used enough selectors or not. That said, you can use normal selectors if you need anything specific. It's just ergonomics.
That looks like it has worked for the testing page
All headers are now Lora, all body font (confirmed via Inspect) is Nunito
So, for a newbie, you define variables just by stating them with --, in common.css, and they refer to something in the citizen css?
Yup, I recommend checking the Computed tab (if you're on Chrome) to confirm the font has loaded
CSS variables (technically, they're called Custom Properties) allow you to set a value and use it elsewhere
Citizen relies on variables so its design is consistent
You can use them, or you can just brute-force your way with normal CSS
They do appear in devtools if you want to check them out
I think I get that, but I don't understand how one can make an arbitrarily named variable and the system knows how that refers to the body font, for example
If you click on that it should scroll to the variable declaration (usually, at :root)
unless it isn't arbitrary, the name of the variable?
I suggested that variable because, as you can see, the original Citizen CSS refers to --font-family-base, which value is var(--font-family-citizen-base), var(--font-family-language-base), system-ui, -apple-system, sans-serif
And down the rabbit hole, --font-family-citizen-base is 'Roboto', 'Roboto-fallback' (originally), so I overwrote it. I could have overwritten html, body {} or --font-family-base as well, but this path was safer.
They're always arbitrary (hence why they're called custom properties). You just need to know which ones Citizen is declaring/using, and devtools will always tell you that
Ah I think I see
So when you're declaring a variable, it isn't just a random name which you're assigning value to, it's an existing value somewhere in the citizen css that you are changing the value of?
oh
noted, I'll see if I can use dev tools in future
Yup
I mean you can declare your own as well
that makes much more sense
I did that in my wiki using Citizen
But yes, Citizen's modern CSS in a way makes it more difficult as you need to be aware of more things
It was worth it for the wiki looking like it is from the 2020s without having to change too many things manually
For example, this is how I changed colors
:root {
--color-progressive-oklch__l: 26.53%;
--color-progressive-oklch__c: .0136;
--color-progressive-oklch__h: 290.72;
--color-surface-0: #f8f8fc;
--color-surface-1-oklch__l: 100%;
--color-surface-1-oklch__c: 0;
--color-surface-2-oklch__c: 0;
--color-visited: #36c;
}
I adjusted the palette and Citizen uses these variables so everything changed cleanly with just a few lines
woah
so if you know what variables you're looking for you can just do a bunch of them within one root
and change them
yup
useful to have them all lined up in the common css like a buffet
Other skins would require you to go down the rabbit hole and find every single selector and pray you didn't miss one
(Cosmos is a special case)
citizen provides their own styling. when you write to your citizen.css, it loads after the default provided values, hence cascading
you can make your own variables, it doesn't have to be the same one citizen is using
So is there a hierarchy of these css files?
Common is above citizen, is above template specific css
yes there is a load order
there was a write up, i can't find it anymore. but off the top of my head it is
Common.css
skinspecific.css (like vector.css)
user common.css
user skinspecific.css (myname/vector.css)
inline css
so if you want to test things before showing everyone, you go to your personal css pages to preview how it would look to the whole world
So to summarise for my and others' future reference:
Question:
How do you change fonts across a wiki using the Citizen skin, with a different font for the body and the headings. These fonts are free fonts imported via url from Google Fonts.
Response:
Common.css should include something like this:
@import url("https://fonts.googleapis.com/css?family=Lora&family=Nunito&display=swap");
:root {
--font-family-citizen-base: Nunito, sans-serif;
}
.mw-heading, .mw-page-title-main {
font-family: Lora;
}
Notes
- In Citizen, you can use root: and variables to change many things about the styling
- Variables can be defined or just refer to ones in other css files and overwrite them
- Use the right import url from Google Fonts, for example: https://fonts.googleapis.com/css?family=Lora&family=Nunito&display=swap
This is the one under Web > Import > Embed code in the head of your html without the weight stuff - Use @import url instead of @font-face
Big thanks to @hardy helm, @sour salmon and @jaunty lake for your time and patience. It is very much appreciated
- user group pages, between user and inline
(not sure why they put it after user, but anyways)
This doesn't load Nunito, by the way
It's declared in the CSS, doesn't mean it's actually loading Nunito
You probably got it installed locally
oh
I do yeah
Hmm
Will be a problem if others use it
Does that mean the import link from google fonts is wrong
They won't see Nunito, they will see the fallback which in my case is Arial
accursed 2009-ass font
What would be the correct import link? Or would it just be trial and error
Well, you can fix the original link but I'd just use this
Lora and Nunito are variable fonts, and the legacy API can't really handle them (it outputs static fixed-width versions). The newer API (css2) does
ahh I see
this is freaky, its made mediawiki the body font and common.css the heading font
oh i forgot citizen separates those lol
Use #firstHeading instead of .mw-page-title-main
seems like its fixed it
Vector 2022 does too
Just in case I come back to this and want to change other heading levels, do you know how i'd find the equivalent of #firstHeading for:
big {(so <big></big>)h2{(so == heading 1 ==)h3{(so ===heading 2===)
(I would discourage using <big>)
But that's a separate conversation 
haha
Well, it is that. But h2 are used in other ways too so I'd use a more specific selector
.mw-heading2, .mw-heading3 { ... }
Really sorry, but does this still need #FirstHeading after it, or something else?
only ask because it reverts back to nunito when I do stuff like <h1 style =>
and not having firstHeading produces an error
Probably because of the comma
Also, <h1-6> use .mw-html-heading
If you want Lora for all headings, .mw-heading, .mw-heading-html, #firstHeading { font-family: Lora; }
I think if I want to change them in future it might be better to have the levels separately, this seems to work:
@import url('https://fonts.googleapis.com/css2?family=Lora:wght@600&family=Nunito:ital@0;1&display=swap');
:root {
--font-family-citizen-base: Nunito, sans-serif;
}
.mw-html-heading, #h1 {
font-family: Lora;
}
.mw-html-heading, #h2 {
font-family: Lora;
}
.mw-html-heading, #h3 {
font-family: Lora;
}
.mw-html-heading, #h4 {
font-family: Lora;
}
shit, no it doesnt. the caching is my worst enemy
I used .mw-html-heading, and it affects <h1 style></h1> within a column template, but not when I just use <h1></h1> more generally:
but does work now
Ah okay, I am using the dev tools/inspect more but still not the most experienced
I give up. No longer works. the delay makes it impossible to test what works.
I'll just wait
I would suggest a browser tool like Stylus to test changes before applying them to Common.css
Thank you
Personally I vouch for https://github.com/webextensions/live-css-editor
Looks like it is working
bookmarking this
Not sure how it's supposed to work actually
installed the extension but not sure where it shows it applied, on the page you're on?
Oh i can pull up the popup thing but when I put the css in it, I'm not sure what I'm supposed to be looking at
That will automatically apply styles to the page
it also auto-saves so even if you accidentally close the tab you keep your CSS
then after you're done testing you move it to Common.css or wherever
oh it shows you if nothing on the page matches whatever you're referring to as well
nice
trying to find a page with something I can easily identify
yup it also higlights them on the page which is handy
use devtools to find HTML selectors
struggling on twitter
X/Twitter and similar platforms usually compile their classes so the HTML isn't particularly readable by humans
I'm really sorry for being dense, what colour will selectors be
should have a red outline
i have mid blue, light blue and orange
uhh stylus or the one i linked?
the one you linked
i'm looking at devtools
just trying to find a selector I can test
iom selecting text but i dont know how to find the selector for that text
like a simple one would be to select some text look in dev tools and find what its called
but i can't find it
Okay so it will be in the middle bar in elements I think
I'd recommend taking a CSS crash course to understand how it works
You can find selectors with either devtools or the extension I linked
Will be a good shout. Even if I just understand what all the definitions are