FAQ: CSS Typography - Font Family

  • Font Family Property: You can specify a font using the font-family property in CSS. This allows you to choose a specific serif or sans-serif font. For example:

    body {
        font-family: "Georgia", serif; /* This specifies a serif font */
    }
    
    h1 {
        font-family: "Arial", sans-serif; /* This specifies a sans-serif font */
    }
    
  • Generic Font Families: In CSS, you can specify generic font families as fallbacks. These include:

    • serif: Any serif font.
    • sans-serif: Any sans-serif font.
    • monospace: A fixed-width font.
    • cursive: A font that resembles handwriting.
    • fantasy: Decorative fonts.For example:
    p {
        font-family: "Times New Roman", serif; /* A specific serif font with a fallback */
    }
    
    .example {
        font-family: "Helvetica Neue", sans-serif; /* A specific sans-serif font with a fallback */
    }