Curriculum
Course: CSS
Login

Curriculum

CSS

CSS INTRODUCTION

0/1

CSS Selectors

0/1

CSS Comments

0/1

CSS Padding

0/1

CSS Box Model

0/1

CSS Combinators

0/1

CSS Pseudo-classes

0/1

CSS Pseudo-elements

0/1

CSS Dropdowns

0/1

CSS Image Gallery

0/1

CSS Image Sprites

0/1

CSS Counters

0/1

CSS Website Layout

0/1

CSS Specificity

0/1

CSS Math Functions

0/1
Text lesson

Google Fonts

Google Fonts

If you wish to avoid utilizing the default fonts available in HTML, Google Fonts offer an alternative solution. With over 1000 fonts available, Google Fonts are freely accessible for use, providing a diverse selection to choose from.

How To Use Google Fonts

Simply insert a specific style sheet link within the <head> section of your HTML document, and subsequently make references to the desired font within your CSS code.

Example

In this case, our intention is to utilize a font called “Sofia” sourced from Google Fonts.

<head>
<link rel=”stylesheet” href=”https://fonts.googleapis.com/css?family=Sofia”>
<style>
body {
  font-family: “Sofia”, sans-serif;
}
</style>
</head>

Result:

IMG_3486

 

Example

In this instance, our objective is to incorporate a font named “Trirong” sourced from Google Fonts.

<head>
<link rel=”stylesheet” href=”https://fonts.googleapis.com/css?family=Trirong”>
<style>
body {
  font-family: “Trirong”, serif;
}
</style>
</head>

Result:

IMG_3487

 

Example

In this context, we aim to apply a font named “Audiowide” sourced from Google Fonts.

<head>
<link rel=”stylesheet” href=”https://fonts.googleapis.com/css?family=Audiowide”>
<style>
body {
  font-family: “Audiowide”, sans-serif;
}
</style>
</head>

Result:

IMG_3488
Reminder: When defining a font in CSS, it’s essential to include at least one fallback font to mitigate unforeseen issues. Therefore, ensure to append a generic font family, such as serif or sans-serif, to the end of the font list.

Use Multiple Google Fonts

To employ multiple Google fonts, simply delineate the font names by using a pipe character (|), as illustrated below:

Example

Request multiple fonts:

<head>
<link rel=”stylesheet” href=”https://fonts.googleapis.com/css?family=Audiowide|Sofia|Trirong”>
<style>
h1.a {font-family: “Audiowide”, sans-serif;}
h1.b {font-family: “Sofia”, sans-serif;}
h1.c {font-family: “Trirong”, serif;}
</style>
</head>

Result:

IMG_3489
Please be mindful that requesting multiple fonts could potentially slow down the loading time of your web pages.

Styling Google Fonts

Certainly, you have the freedom to customize Google Fonts to your preferences using CSS!

Example

Style the “Sofia” font:

<head>
<link rel=”stylesheet” href=”https://fonts.googleapis.com/css?family=Sofia”>
<style>
body {
  font-family: “Sofia”, sans-serif;
  font-size: 30px;
  text-shadow: 3px 3px 3px #ababab;
}
</style>
</head>

Result:

IMG_3490

Enabling Font Effects

Google has introduced various font effects that you can utilize.

Start by incorporating effect=effectname into the Google API, and then assign a unique class name to the element intended for the special effect. Ensure that the class name commences with font-effect- and concludes with the effectname.

Example

Add the fire effect to the “Sofia” font:

<head>
<link rel=”stylesheet” href=”https://fonts.googleapis.com/css?family=Sofia&effect=fire”>
<style>
body {
  font-family: “Sofia”, sans-serif;
  font-size: 30px;
}
</style>
</head>
<body>

<h1 class=”font-effect-fire”>Sofia on Fire</h1>

</body>

Result:

IMG_3491

To request multiple font effects, simply separate the effect names using a pipe character (|), as demonstrated below:

Example

Add multiple effects to the “Sofia” font:

<head>
<link rel=”stylesheet” href=”https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple”>
<style>
body {
  font-family: “Sofia”, sans-serif;
  font-size: 30px;
}
</style>
</head>
<body>

<h1 class=”font-effect-neon”>Neon Effect</h1>
<h1 class=”font-effect-outline”>Outline Effect</h1>
<h1 class=”font-effect-emboss”>Emboss Effect</h1>
<h1 class=”font-effect-shadow-multiple”>Multiple Shadow Effect</h1>

</body>

Result:

IMG_3492