Search
Close this search box.
Course Content
CSS Basic
0/1
CSS Selectors
0/1
CSS Comments
0/1
CSS Backgrounds
0/1
CSS Borders
0/1
CSS Outline
0/1
CSS Fonts
0/1
CSS Height and Width
0/1
CSS Margins and Paddings
0/2
CSS Icons
0/1
CSS Links
0/1
CSS Lists
0/1
CSS Tables
0/1
CSS Display Properties
0/1
CSS Max-Width Property
0/1
CSS Positioning Elements
0/1
CSS Z-Index Property
0/1
CSS Overflow
0/1
CSS Float
0/1
CSS Opacity
0/1
CSS Forms
0/1
CSS Dropdowns
0/1
CSS Buttons
0/1
CSS Media Queries
0/1
About Lesson

Basic font families are generic font families that are commonly available across different operating systems and devices. They are defined by the CSS specification and provide fallback options in case the preferred font is not available. Here are some of the basic font families:

Fonts with small decorative lines at the ends of characters.

Times New Roman, Georgia, serif

Fonts without decorative lines at the ends of characters, often considered more modern and clean.

Arial, Helvetica, sans-serif

Fonts where each character occupies the same amount of horizontal space.

Courier New, Courier, monospace

Fonts that mimic handwriting styles.

Comic Sans MS, cursive

Fonts with decorative elements or unusual designs.

Impact, fantasy

When specifying font families in CSS, it’s a good practice to provide a list of fallback fonts to ensure that the browser can render text even if the preferred font is not available. For example:

body {
  font-family: Arial, Helvetica, sans-serif;
}

In this example, the browser will first attempt to use Arial, then Helvetica, and finally fall back to any available sans-serif font if neither Arial nor Helvetica is available.

Using basic font families helps ensure consistent text rendering across different platforms and devices, even if specific fonts are not installed or supported.

HTML
<!DOCTYPE html>
<html lang="en">
<head>
       
    <meta charset="UTF-8">
       
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Text Formatting</title>
    <style>
        
    </style>
</head>

<body>
    <h1>Font-Family Property</h1>
    <p class="serif">This is a serif font.</p>
    <p class="sans-serif">This is a sans-serif font.</p>
    <p class="monospace">This is a monospace font.</p>
    <p class="cursive">This is a cursive font.</p>
    <p class="fantasy">This is a fantasy font.</p>
</body>


</html>
CSS
        .serif {
            font-family: "Times New Roman", Times, serif;
        }

        .sans-serif {
            font-family: Arial, Helvetica, sans-serif;
        }

        .monospace {
            font-family: "Courier New", Courier, monospace;
        }

        .cursive {
            font-family: "Comic Sans MS", cursive;
        }

        .fantasy {
            font-family: Impact, fantasy;
        }