How do I specify a fonts in css?
-
Also see: https://www.w3schools.com/css/css_font.asp
Note: Font names with more than one word should be in quotes. The CSS font-family will use the first available font when more than one font is specified.
Sample html element to demonstrate CSS fonts.
... <h1>Lorem ipsum dolor sit amet</h1> ...
Without any CSS font change it looks like this by default.
The CSS code to change the font to Generic Font Monospace, using the CSS property font-family.
<style> h1 { font-family: Monospace } </style>
It now will look like this.
Under the
Monospace
font family we have a font namedCourier New
.<style> h1 { font-family: monospace, 'Courier New' } </style>
The result is:
Note: You can also link or impor external fonts in CSS.
© Lightnetics 2024