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.
    8fc4d640-e0e4-4f40-bc7e-a9e158d59e5e-image.png

    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.
    5cd40876-cad4-436c-b657-526237d5d4a6-image.png

    Under the Monospace font family we have a font named Courier New.

     <style>
            h1 {
                font-family: monospace, 'Courier New'
            }
        </style>
    

    The result is:
    dab3e625-0af5-4061-85b6-c9db7f68c102-image.png

    Note: You can also link or impor external fonts in CSS.


Log in to reply
 

© Lightnetics 2024